]> granicus.if.org Git - php/commitdiff
Fixed bug #79282
authorStanislav Malyshev <stas@php.net>
Mon, 16 Mar 2020 00:26:00 +0000 (17:26 -0700)
committerStanislav Malyshev <stas@php.net>
Mon, 16 Mar 2020 00:26:00 +0000 (17:26 -0700)
ext/exif/exif.c
ext/exif/tests/bug79282.phpt [new file with mode: 0644]

index 7fe055f381d792da9c3a6678647800ab58fa834a..819708c2d3359dba9ed7004955b450c6ed83b7ff 100644 (file)
@@ -3692,6 +3692,11 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
 {
        unsigned exif_value_2a, offset_of_ifd;
 
+       if (length < 2) {
+               exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
+               return;
+       }
+
        /* set the thumbnail stuff to nothing so we can test to see if they get set up */
        if (memcmp(CharBuf, "II", 2) == 0) {
                ImageInfo->motorola_intel = 0;
@@ -3844,7 +3849,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
                        return FALSE;
                }
 
-               sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
+               sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
                Data = ImageInfo->file.list[sn].data;
 
                /* Store first two pre-read bytes. */
diff --git a/ext/exif/tests/bug79282.phpt b/ext/exif/tests/bug79282.phpt
new file mode 100644 (file)
index 0000000..7b7e365
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #79282: Use-of-uninitialized-value in exif
+--FILE--
+<?php
+
+var_dump(exif_read_data('data://image/jpeg;base64,/9jhAAlFeGlmAAAg'));
+
+?>
+--EXPECTF--
+Warning: exif_read_data(): Invalid TIFF alignment marker in %s on line %d
+
+Warning: exif_read_data(): File structure corrupted in %s on line %d
+
+Warning: exif_read_data(): Invalid JPEG file in %s on line %d
+bool(false)