]> granicus.if.org Git - libjpeg-turbo/commitdiff
TJBench: Fix FPE when decompressing 0-width JPEG
authorDRC <information@libjpeg-turbo.org>
Wed, 2 Jan 2019 03:08:27 +0000 (21:08 -0600)
committerDRC <information@libjpeg-turbo.org>
Wed, 2 Jan 2019 03:14:50 +0000 (21:14 -0600)
Fixes #319

ChangeLog.md
tjbench.c

index 07b880828ac77f55590eb32952a19ea2afe913c2..ebe26b66451ebf5bf547fcf6a53b246c72694037 100644 (file)
@@ -18,6 +18,10 @@ using the `tjLoadImage()` function.
 decompress a specially-crafted malformed JPEG image to a 256-color BMP using
 djpeg.
 
+4. Fixed a floating-point exception that occurred when attempting to
+decompress a specially-crafted malformed JPEG image with a specified image
+width or height of 0 using the C version of TJBench.
+
 
 2.0.1
 =====
index 863e534f9cb4e218fa81c17c1cc1f6dba77af06f..0eb41d50403c193d2eafb5b22e9d33a17e987542 100644 (file)
--- a/tjbench.c
+++ b/tjbench.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2009-2018 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2009-2019 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -541,6 +541,8 @@ int decompTest(char *fileName)
   if (tjDecompressHeader3(handle, srcBuf, srcSize, &w, &h, &subsamp,
                           &cs) == -1)
     _throwtj("executing tjDecompressHeader3()");
+  if (w < 1 || h < 1)
+    _throw("reading JPEG header", "Invalid image dimensions");
   if (cs == TJCS_YCCK || cs == TJCS_CMYK) {
     pf = TJPF_CMYK;  ps = tjPixelSize[pf];
   }