]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.2' into PHP-7.3
authorStanislav Malyshev <stas@php.net>
Mon, 16 Dec 2019 18:04:03 +0000 (10:04 -0800)
committerChristoph M. Becker <cmbecker69@gmx.de>
Tue, 17 Dec 2019 08:33:21 +0000 (09:33 +0100)
* PHP-7.2:
  Fix test
  Fix bug #78793

(cherry picked from commit 5cb4686753a853cb07844feb2b082b409fd7e880)

ext/exif/exif.c
ext/exif/tests/bug76557.phpt
ext/exif/tests/bug78793.phpt [new file with mode: 0644]

index afc299846e2378be69a35738ea67ce4c9bc32585..f6dd08e881996a1ef350a77a6eb5a2bcae457f6d 100644 (file)
@@ -3213,8 +3213,9 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
        }
 
        for (de=0;de<NumDirEntries;de++) {
-               if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de,
-                                                                 offset_base, data_len, displacement, section_index, 0, maker_note->tag_table)) {
+               size_t offset = 2 + 12 * de;
+               if (!exif_process_IFD_TAG(ImageInfo, dir_start + offset,
+                                                                 offset_base, data_len - offset, displacement, section_index, 0, maker_note->tag_table)) {
                        return FALSE;
                }
        }
index 0b48b792ea96865a1df6845130be469720ee5da6..162e8d99a593f6e28aa7f48a350e02a13be12166 100644 (file)
@@ -70,7 +70,7 @@ Warning: exif_read_data(bug76557.jpg): Process tag(x3030=UndefinedTa): Illegal f
 
 Warning: exif_read_data(bug76557.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %sbug76557.php on line %d
 
-Warning: exif_read_data(bug76557.jpg): Process tag(x3030=UndefinedTa): Illegal pointer offset(x30303030 + x30303030 = x60606060 > x00EE) in %sbug76557.php on line %d
+Warning: exif_read_data(bug76557.jpg): Process tag(x3030=UndefinedTa): Illegal pointer offset(x30303030 + x30303030 = x60606060 > %s) in %sbug76557.php on line %d
 
 Warning: exif_read_data(bug76557.jpg): File structure corrupted in %sbug76557.php on line %d
 
diff --git a/ext/exif/tests/bug78793.phpt b/ext/exif/tests/bug78793.phpt
new file mode 100644 (file)
index 0000000..033f255
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #78793: Use-after-free in exif parsing under memory sanitizer
+--FILE--
+<?php
+$f = "ext/exif/tests/bug77950.tiff";
+for ($i = 0; $i < 10; $i++) {
+    @exif_read_data($f);
+}
+?>
+===DONE===
+--EXPECT--
+===DONE===