Browse Source
Merge branch 'PHP-5.6'
Merge branch 'PHP-5.6'
* PHP-5.6: (27 commits) fix non-standard C update NEWS 5.4.41 next fix CVE num update NEWS Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode) fix test fix type in fix for #69085 fix memory leak & add test Fix tests fix CVE num Fix bug #69337 (php_stream_url_wrap_http_ex() type-confusion vulnerability) Fix test Additional fix for bug #69324 More fixes for bug #69152 Fixed bug #69353 (Missing null byte checks for paths in various PHP extensions) Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar) Fixed bug #69316 (Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER) Fix bug #68486 and bug #69218 (segfault in apache2handler with apache 2.4) Fix bug #68819 (Fileinfo on specific file causes spurious OOM and/or segfault) ... Conflicts: Zend/zend_exceptions.c ext/curl/interface.c ext/dom/document.c ext/fileinfo/libmagic/softmagic.c ext/gd/gd.c ext/hash/hash.c ext/pgsql/pgsql.c ext/phar/phar.c ext/phar/phar_internal.h ext/standard/http_fopen_wrapper.c ext/standard/link.c ext/standard/streamsfuncs.c ext/xmlwriter/php_xmlwriter.c ext/zlib/zlib.cpull/1239/head
33 changed files with 320 additions and 81 deletions
-
3Zend/zend_exceptions.c
-
5ext/curl/interface.c
-
45ext/curl/tests/bug69316.phpt
-
8ext/dom/document.c
-
5ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
-
5ext/fileinfo/fileinfo.c
-
9ext/fileinfo/libmagic/softmagic.c
-
18ext/fileinfo/tests/bug68819_001.phpt
-
26ext/fileinfo/tests/bug68819_002.phpt
-
4ext/fileinfo/tests/finfo_file_basic.phpt
-
6ext/gd/gd.c
-
2ext/gd/tests/imageloadfont_error1.phpt
-
7ext/hash/hash.c
-
7ext/hash/tests/hash_hmac_file_error.phpt
-
2ext/pgsql/pgsql.c
-
72ext/phar/phar.c
-
11ext/phar/phar_internal.h
-
BINext/phar/tests/bug69324.phar
-
17ext/phar/tests/bug69324.phpt
-
BINext/phar/tests/bug69441.phar
-
21ext/phar/tests/bug69441.phpt
-
14ext/standard/http_fopen_wrapper.c
-
2ext/standard/link.c
-
2ext/standard/streamsfuncs.c
-
2ext/standard/tests/file/readlink_variation1.phpt
-
41ext/standard/tests/http/bug69337.phpt
-
16ext/standard/tests/serialize/bug69152.phpt
-
4ext/xmlwriter/php_xmlwriter.c
-
28ext/zlib/tests/gzopen_variation1.phpt
-
10ext/zlib/tests/readgzfile_variation1.phpt
-
4ext/zlib/tests/readgzfile_variation6.phpt
-
4ext/zlib/zlib.c
-
1sapi/apache2handler/sapi_apache2.c
@ -0,0 +1,45 @@ |
|||
--TEST-- |
|||
Bug #69316: Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER |
|||
--SKIPIF-- |
|||
<?php include 'skipif.inc'; ?> |
|||
--FILE-- |
|||
<?php |
|||
function hdr_callback($ch, $data) { |
|||
// close the stream, causing the FILE structure to be free()'d |
|||
if($GLOBALS['f_file']) { |
|||
fclose($GLOBALS['f_file']); $GLOBALS['f_file'] = 0; |
|||
|
|||
// cause an allocation of approx the same size as a FILE structure, size varies a bit depending on platform/libc |
|||
$FILE_size = (PHP_INT_SIZE == 4 ? 0x160 : 0x238); |
|||
curl_setopt($ch, CURLOPT_COOKIE, str_repeat("a", $FILE_size - 1)); |
|||
} |
|||
return strlen($data); |
|||
} |
|||
|
|||
include 'server.inc'; |
|||
$host = curl_cli_server_start(); |
|||
$temp_file = dirname(__FILE__) . '/body.tmp'; |
|||
$url = "{$host}/get.php?test=getpost"; |
|||
$ch = curl_init(); |
|||
$f_file = fopen($temp_file, "w") or die("failed to open file\n"); |
|||
curl_setopt($ch, CURLOPT_BUFFERSIZE, 10); |
|||
curl_setopt($ch, CURLOPT_HEADERFUNCTION, "hdr_callback"); |
|||
curl_setopt($ch, CURLOPT_FILE, $f_file); |
|||
curl_setopt($ch, CURLOPT_URL, $url); |
|||
curl_exec($ch); |
|||
curl_close($ch); |
|||
?> |
|||
===DONE=== |
|||
--CLEAN-- |
|||
<?php |
|||
unlink(dirname(__FILE__) . '/body.tmp'); |
|||
?> |
|||
--EXPECTF-- |
|||
Warning: curl_exec(): CURLOPT_FILE resource has gone away, resetting to default in %s on line %d |
|||
array(1) { |
|||
["test"]=> |
|||
string(7) "getpost" |
|||
} |
|||
array(0) { |
|||
} |
|||
===DONE=== |
|||
18
ext/fileinfo/tests/bug68819_001.phpt
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,26 @@ |
|||
--TEST-- |
|||
Bug #68819 Fileinfo on specific file causes spurious OOM and/or segfault, var 2 |
|||
--SKIPIF-- |
|||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$string = ''; |
|||
|
|||
// These two in any order |
|||
$string .= "\r\n"; |
|||
$string .= "''''"; |
|||
|
|||
// Total string length > 8192 |
|||
$string .= str_repeat(chr(rand(32, 127)), 8184); |
|||
|
|||
// Ending in this string |
|||
$string .= "say"; |
|||
|
|||
$finfo = new finfo(); |
|||
$type = $finfo->buffer($string); |
|||
var_dump($type); |
|||
|
|||
?> |
|||
--EXPECT-- |
|||
string(60) "ASCII text, with very long lines, with CRLF line terminators" |
|||
@ -0,0 +1,17 @@ |
|||
--TEST-- |
|||
Bug #69324: Buffer Over-read in unserialize when parsing Phar |
|||
--SKIPIF-- |
|||
<?php |
|||
if (!extension_loaded("phar")) die("skip"); |
|||
?> |
|||
--FILE-- |
|||
<?php |
|||
try { |
|||
$p = new Phar(dirname(__FILE__).'/bug69324.phar', 0); |
|||
$meta=$p->getMetadata(); |
|||
var_dump($meta); |
|||
} catch(Exception $e) { |
|||
echo $e->getMessage(); |
|||
} |
|||
--EXPECTF-- |
|||
internal corruption of phar "%s" (truncated manifest entry) |
|||
@ -0,0 +1,21 @@ |
|||
--TEST-- |
|||
Phar: bug #69441: Buffer Overflow when parsing tar/zip/phar in phar_set_inode |
|||
--SKIPIF-- |
|||
<?php if (!extension_loaded("phar")) die("skip"); ?> |
|||
--FILE-- |
|||
<?php |
|||
$fname = dirname(__FILE__) . '/bug69441.phar'; |
|||
try { |
|||
$r = new Phar($fname, 0); |
|||
} catch(UnexpectedValueException $e) { |
|||
echo $e; |
|||
} |
|||
?> |
|||
|
|||
==DONE== |
|||
--EXPECTF-- |
|||
exception 'UnexpectedValueException' with message 'phar error: corrupted central directory entry, no magic signature in zip-based phar "%s/bug69441.phar"' in %s/bug69441.php:%d |
|||
Stack trace: |
|||
#0 %s/bug69441.php(%d): Phar->__construct('%s', 0) |
|||
#1 {main} |
|||
==DONE== |
|||
@ -0,0 +1,41 @@ |
|||
--TEST-- |
|||
Bug #69337 (Stream context leaks when http request fails) |
|||
--SKIPIF-- |
|||
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:22345'); ?> |
|||
--INI-- |
|||
allow_url_fopen=1 |
|||
allow_url_include=1 |
|||
--FILE-- |
|||
<?php |
|||
require 'server.inc'; |
|||
|
|||
function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) |
|||
{ |
|||
if($notification_code == STREAM_NOTIFY_REDIRECTED) { |
|||
// $http_response_header is now a string, but will be used as an array |
|||
// by php_stream_url_wrap_http_ex() later on |
|||
$GLOBALS['http_response_header'] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\0\0\0\0"; |
|||
} |
|||
} |
|||
|
|||
$ctx = stream_context_create(); |
|||
stream_context_set_params($ctx, array("notification" => "stream_notification_callback")); |
|||
|
|||
$responses = array( |
|||
"data://text/plain,HTTP/1.0 302 Found\r\nLocation: http://127.0.0.1:22345/try-again\r\n\r\n", |
|||
"data://text/plain,HTTP/1.0 404 Not Found\r\n\r\n", |
|||
); |
|||
|
|||
$pid = http_server("tcp://127.0.0.1:22345", $responses, $output); |
|||
|
|||
$f = file_get_contents('http://127.0.0.1:22345/', 0, $ctx); |
|||
|
|||
http_server_kill($pid); |
|||
var_dump($f); |
|||
?> |
|||
==DONE== |
|||
--EXPECTF-- |
|||
string(26) "HTTP/1.0 404 Not Found |
|||
|
|||
" |
|||
==DONE== |
|||
@ -0,0 +1,16 @@ |
|||
--TEST-- |
|||
Bug #69152: Type Confusion Infoleak Vulnerability in unserialize() |
|||
--FILE-- |
|||
<?php |
|||
$x = unserialize('O:9:"exception":1:{s:16:"'."\0".'Exception'."\0".'trace";s:4:"ryat";}'); |
|||
echo $x; |
|||
$x = unserialize('O:4:"test":1:{s:27:"__PHP_Incomplete_Class_Name";R:1;}'); |
|||
$x->test(); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
exception 'Exception' in %s:%d |
|||
Stack trace: |
|||
#0 {main} |
|||
|
|||
Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "unknown" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in %s on line %d |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue