summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2015-01-20 10:41:59 -0800
committerStanislav Malyshev <stas@php.net>2015-01-20 10:41:59 -0800
commitb16fdebcf8f59e5aa09c11782c05224762ca835e (patch)
treee99d54657906281f4755e859bfe6400eda811ab1
parentea8415114a9299f6ba7df16c882e6d9d328af054 (diff)
parente18ec956873d1cc1fcd4647f4a218c25d0f80209 (diff)
downloadphp-git-b16fdebcf8f59e5aa09c11782c05224762ca835e.tar.gz
Merge branch 'PHP-5.6'
* PHP-5.6: 5.4.38 next Updated NEWS Updated NEWS Fix bug #68711 Remove useless checks. 'num' is unsigned and cannot be <0. Fix bug #68799: Free called on unitialized pointer Fix for bug #68710 (Use After Free Vulnerability in PHP's unserialize()) Conflicts: ext/exif/exif.c ext/standard/var_unserializer.c ext/standard/var_unserializer.re
-rw-r--r--ext/exif/exif.c2
-rw-r--r--ext/exif/tests/bug68799.jpgbin0 -> 735 bytes
-rw-r--r--ext/exif/tests/bug68799.phpt63
-rw-r--r--ext/standard/tests/strings/bug68710.phpt25
4 files changed, 89 insertions, 1 deletions
diff --git a/ext/exif/exif.c b/ext/exif/exif.c
index d889db06fd..0e25a05cf2 100644
--- a/ext/exif/exif.c
+++ b/ext/exif/exif.c
@@ -2695,7 +2695,7 @@ static int exif_process_user_comment(image_info_type *ImageInfo, char **pszInfoP
static int exif_process_unicode(image_info_type *ImageInfo, xp_field_type *xp_field, int tag, char *szValuePtr, int ByteCount)
{
xp_field->tag = tag;
-
+ xp_field->value = NULL;
/* XXX this will fail again if encoding_converter returns on error something different than SIZE_MAX */
if (zend_multibyte_encoding_converter(
(unsigned char**)&xp_field->value,
diff --git a/ext/exif/tests/bug68799.jpg b/ext/exif/tests/bug68799.jpg
new file mode 100644
index 0000000000..acc326dbbf
--- /dev/null
+++ b/ext/exif/tests/bug68799.jpg
Binary files differ
diff --git a/ext/exif/tests/bug68799.phpt b/ext/exif/tests/bug68799.phpt
new file mode 100644
index 0000000000..b09f21ca7b
--- /dev/null
+++ b/ext/exif/tests/bug68799.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Bug #68799 (Free called on unitialized pointer)
+--SKIPIF--
+<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
+--FILE--
+<?php
+/*
+* Pollute the heap. Helps trigger bug. Sometimes not needed.
+*/
+class A {
+ function __construct() {
+ $a = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa';
+ $this->a = $a . $a . $a . $a . $a . $a;
+ }
+};
+
+function doStuff ($limit) {
+
+ $a = new A;
+
+ $b = array();
+ for ($i = 0; $i < $limit; $i++) {
+ $b[$i] = clone $a;
+ }
+
+ unset($a);
+
+ gc_collect_cycles();
+}
+
+$iterations = 3;
+
+doStuff($iterations);
+doStuff($iterations);
+
+gc_collect_cycles();
+
+print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
+
+?>
+--EXPECTF--
+Array
+(
+ [FileName] => bug68799.jpg
+ [FileDateTime] => %d
+ [FileSize] => 735
+ [FileType] => 2
+ [MimeType] => image/jpeg
+ [SectionsFound] => ANY_TAG, IFD0, WINXP
+ [COMPUTED] => Array
+ (
+ [html] => width="1" height="1"
+ [Height] => 1
+ [Width] => 1
+ [IsColor] => 1
+ [ByteOrderMotorola] => 1
+ )
+
+ [XResolution] => 96/1
+ [YResolution] => 96/1
+ [ResolutionUnit] => 2
+ [Author] =>
+)
diff --git a/ext/standard/tests/strings/bug68710.phpt b/ext/standard/tests/strings/bug68710.phpt
new file mode 100644
index 0000000000..729a12011b
--- /dev/null
+++ b/ext/standard/tests/strings/bug68710.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #68710 Use after free vulnerability in unserialize() (bypassing the
+CVE-2014-8142 fix)
+--FILE--
+<?php
+for ($i=4; $i<100; $i++) {
+ $m = new StdClass();
+
+ $u = array(1);
+
+ $m->aaa = array(1,2,&$u,4,5);
+ $m->bbb = 1;
+ $m->ccc = &$u;
+ $m->ddd = str_repeat("A", $i);
+
+ $z = serialize($m);
+ $z = str_replace("aaa", "123", $z);
+ $z = str_replace("bbb", "123", $z);
+ $y = unserialize($z);
+ $z = serialize($y);
+}
+?>
+===DONE===
+--EXPECTF--
+===DONE===