]> granicus.if.org Git - php/commitdiff
Fix bug #67250 (iptcparse out-of-bounds read)
authorStanislav Malyshev <stas@php.net>
Mon, 12 May 2014 02:09:19 +0000 (19:09 -0700)
committerStanislav Malyshev <stas@php.net>
Mon, 12 May 2014 02:09:19 +0000 (19:09 -0700)
NEWS
ext/standard/iptc.c
ext/standard/tests/image/bug67250.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 03f8b87daf95e520b8158f7e35dcb18bd3cf2bd2..6e2ff759ffec30abe940e11b173e5d887dc11e5b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP                                                                        NEWS
   . Fixed bug #67245 (usage of memcpy() with overlapping src and dst in
     zend_exceptions.c). (Bob)
   . Fixed bug #67247 (spl_fixedarray_resize integer overflow). (Stas)
+  . Fixed bug #67250 (iptcparse out-of-bounds read). (Stas)
 
 - Date:
   . Fixed bug #67118 (DateTime constructor crash with invalid data). (Anatol)
index 3257339106417dad756b041a4b0fb8b87e726a18..d2c14c98c7f4fa531b3fcd043c7d6910324d0e77 100644 (file)
@@ -329,6 +329,9 @@ PHP_FUNCTION(iptcparse)
                recnum = buffer[ inx++ ];
 
                if (buffer[ inx ] & (unsigned char) 0x80) { /* long tag */
+            if((inx+6) >= str_len) {
+                break;
+            }
                        len = (((long) buffer[ inx + 2 ]) << 24) + (((long) buffer[ inx + 3 ]) << 16) + 
                                  (((long) buffer[ inx + 4 ]) <<  8) + (((long) buffer[ inx + 5 ]));
                        inx += 6;
diff --git a/ext/standard/tests/image/bug67250.phpt b/ext/standard/tests/image/bug67250.phpt
new file mode 100644 (file)
index 0000000..607de9f
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #67250 (iptcparse out-of-bounds read)
+--FILE--
+<?php
+var_dump(iptcparse("\x1C\x02_\x80___"));
+?>
+--EXPECT--
+bool(false)