GNOME Bugzilla – Bug 780269
CVE-2017-2870 Gdk-Pixbuf TIFF tiff_image_parse Code Execution Vunerability (integer overflow)
Last modified: 2017-08-25 19:41:29 UTC
Created attachment 348263 [details] [review] patch I seems the current checks for multiplication overflows rely on undefined behaviour are are thus not reliable. afl produced a file that makes the tiff loader code behave undefinedly (according the UBSan): io-tiff.c:127:19: runtime error: signed integer overflow: 1073741824 * 4 cannot be represented in type 'int' Attached is a patch by Ludovico which makes the issue disappear. The patch looks innocent enough to me. Too sad that we don't have a g_int_checked_mul(). I tried to find out whether coverity also complains, but I can't access it atm, probably due to maintenance work on their side.
Created attachment 348264 [details] example file
I probably shouldn't have opened this bug report because there is already a bug report: bug 770986. Now even with an alternative patch.
*** Bug 784903 has been marked as a duplicate of this bug. ***
Review of attachment 348263 [details] [review]: Commit message needs work.
Comment on attachment 348264 [details] example file Example file should be in a git formatted patch.
Created attachment 355519 [details] [review] added the crashing file
Created attachment 355524 [details] [review] patch with more descriptive message Amended the patch with a more informative commit message.
Created attachment 355537 [details] [review] tiff: Check for integer overflows in multiplication The checks currently in use are not sufficient, because they depend on undefined behaviour: rowstride = width * 4; if (rowstride / 4 != width) { /* overflow */ If the multiplication has already overflowed, the compiler may decide to optimize the if out and thus we do not handle the erroneous case. Rearrange the checks to avoid the undefined behaviour. Note that gcc doesn't seem to be impacted, though a defined behaviour is obviously preferred. CVE-2017-2870
Attachment 355537 [details] pushed as 31a6cff - tiff: Check for integer overflows in multiplication