Skip to content

Commit d3aeb8a

Browse files
committed
Merge branch 'PHP-5.4.40' into PHP-5.4
* PHP-5.4.40: update NEWS Fix bug #69441 (Buffer Overflow when parsing tar/zip/phar in phar_set_inode) 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)
2 parents ae46d1c + d734e75 commit d3aeb8a

34 files changed

+382
-128
lines changed

NEWS

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 2015 PHP 5.4.40
3+
16 Apr 2015 PHP 5.4.40
4+
5+
- Apache2handler:
6+
. Fixed bug #69218 (potential remote code execution with apache 2.4
7+
apache2handler). (Gerrit Venema)
8+
9+
- Core:
10+
. Additional fix for bug #69152 (Type confusion vulnerability in
11+
exception::getTraceAsString). (Stas)
12+
. Fixed bug #69337 (php_stream_url_wrap_http_ex() type-confusion
13+
vulnerability). (Stas)
14+
. Fixed bug #69353 (Missing null byte checks for paths in various PHP
15+
extensions). (Stas)
16+
17+
- cURL:
18+
. Fixed bug #69316 (Use-after-free in php_curl related to
19+
CURLOPT_FILE/_INFILE/_WRITEHEADER). (Laruence)
420

521
- Ereg:
622
. Fixed bug #68740 (NULL Pointer Dereference). (Laruence)
723

24+
- Fileinfo:
25+
. Fixed bug #68819 (Fileinfo on specific file causes spurious OOM and/or
26+
segfault). (Anatol Belski)
27+
828
- GD:
929
. Fixed bug #68601 (buffer read overflow in gd_gif_in.c). (Remi)
1030

31+
- Phar:
32+
. Fixed bug #68901 (use after free). (bugreports at internot dot info)
33+
. Fixed bug #69324 (Buffer Over-read in unserialize when parsing Phar). (Stas)
34+
. Fixed bug #69441 (Buffer Overflow when parsing tar/zip/phar in
35+
phar_set_inode). (Stas)
36+
37+
- Postgres:
38+
. Fixed bug #68741 (Null pointer deference) (CVE-2015-1352). (Xinchen Hui)
39+
1140
- SOAP:
1241
. Fixed bug #69152 (Type Confusion Infoleak Vulnerability in unserialize()
1342
with SoapFault). (Dmitry)
1443

1544
- Sqlite3:
1645
. Fixed bug #66550 (SQLite prepared statement use-after-free). (Sean Heelan)
1746

18-
- Phar:
19-
. Fixed bug #68901 (use after free). (bugreports at internot dot info)
20-
21-
- Postgres:
22-
. Fixed bug #68741 (Null pointer deference) (CVE-2015-1352). (Xinchen Hui)
23-
2447
19 Mar 2015 PHP 5.4.39
2548

2649
- Core:

Zend/zend_exceptions.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ ZEND_METHOD(exception, getTraceAsString)
591591
str = &res;
592592

593593
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
594+
if(Z_TYPE_P(trace) != IS_ARRAY) {
595+
RETURN_FALSE;
596+
}
594597
zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 3, str, len, &num);
595598

596599
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);

ext/curl/interface.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
10511051
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION");
10521052
length = -1;
10531053
} else if (retval_ptr) {
1054+
_php_curl_verify_handlers(ch, 1 TSRMLS_CC);
10541055
if (Z_TYPE_P(retval_ptr) != IS_LONG) {
10551056
convert_to_long_ex(&retval_ptr);
10561057
}
@@ -1124,6 +1125,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
11241125
if (error == FAILURE) {
11251126
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
11261127
} else if (retval_ptr) {
1128+
_php_curl_verify_handlers(ch, 1 TSRMLS_CC);
11271129
if (Z_TYPE_P(retval_ptr) != IS_LONG) {
11281130
convert_to_long_ex(&retval_ptr);
11291131
}
@@ -1200,6 +1202,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
12001202
length = CURL_READFUNC_ABORT;
12011203
#endif
12021204
} else if (retval_ptr) {
1205+
_php_curl_verify_handlers(ch, 1 TSRMLS_CC);
12031206
if (Z_TYPE_P(retval_ptr) == IS_STRING) {
12041207
length = MIN((int) (size * nmemb), Z_STRLEN_P(retval_ptr));
12051208
memcpy(data, Z_STRVAL_P(retval_ptr), length);
@@ -1274,6 +1277,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
12741277
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not call the CURLOPT_HEADERFUNCTION");
12751278
length = -1;
12761279
} else if (retval_ptr) {
1280+
_php_curl_verify_handlers(ch, 1 TSRMLS_CC);
12771281
if (Z_TYPE_P(retval_ptr) != IS_LONG) {
12781282
convert_to_long_ex(&retval_ptr);
12791283
}

ext/curl/tests/bug69316.phpt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Bug #69316: Use-after-free in php_curl related to CURLOPT_FILE/_INFILE/_WRITEHEADER
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("curl")) exit("skip curl extension not loaded");
6+
if (false === getenv('PHP_CURL_HTTP_REMOTE_SERVER')) exit("skip PHP_CURL_HTTP_REMOTE_SERVER env variable is not defined");
7+
?>
8+
--FILE--
9+
<?php
10+
function hdr_callback($ch, $data) {
11+
// close the stream, causing the FILE structure to be free()'d
12+
if($GLOBALS['f_file']) {
13+
fclose($GLOBALS['f_file']); $GLOBALS['f_file'] = 0;
14+
15+
// cause an allocation of approx the same size as a FILE structure, size varies a bit depending on platform/libc
16+
$FILE_size = (PHP_INT_SIZE == 4 ? 0x160 : 0x238);
17+
curl_setopt($ch, CURLOPT_COOKIE, str_repeat("a", $FILE_size - 1));
18+
}
19+
return strlen($data);
20+
}
21+
$host = getenv('PHP_CURL_HTTP_REMOTE_SERVER');
22+
23+
$temp_file = dirname(__FILE__) . '/body.tmp';
24+
$url = "{$host}/get.php?test=getpost";
25+
$ch = curl_init();
26+
$f_file = fopen($temp_file, "w") or die("failed to open file\n");
27+
curl_setopt($ch, CURLOPT_BUFFERSIZE, 10);
28+
curl_setopt($ch, CURLOPT_HEADERFUNCTION, "hdr_callback");
29+
curl_setopt($ch, CURLOPT_FILE, $f_file);
30+
curl_setopt($ch, CURLOPT_URL, $url);
31+
curl_exec($ch);
32+
curl_close($ch);
33+
?>
34+
===DONE===
35+
--CLEAN--
36+
<?php
37+
unlink(dirname(__FILE__) . '/body.tmp');
38+
?>
39+
--EXPECTF--
40+
Warning: curl_exec(): CURLOPT_FILE resource has gone away, resetting to default in %s on line %d
41+
===DONE===

ext/dom/document.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc
15801580
xmlInitParser();
15811581

15821582
if (mode == DOM_LOAD_FILE) {
1583+
if (CHECK_NULL_PATH(source, source_len)) {
1584+
return NULL;
1585+
}
15831586
char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC);
15841587
if (file_dest) {
15851588
ctxt = xmlCreateFileParserCtxt(file_dest);
@@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
21682171

21692172
id = getThis();
21702173

2171-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
2174+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
21722175
return;
21732176
}
21742177

ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ assert.bail=true
1313
$doc = new DOMDocument();
1414
$result = $doc->loadHTMLFile("");
1515
assert('$result === false');
16+
$doc = new DOMDocument();
17+
$result = $doc->loadHTMLFile("text.html\0something");
18+
assert('$result === null');
1619
?>
1720
--EXPECTF--
1821
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s
22+
23+
%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile() expects parameter 1 to be a valid path, string given %s

ext/fileinfo/fileinfo.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
506506
RETVAL_FALSE;
507507
goto clean;
508508
}
509+
if (CHECK_NULL_PATH(buffer, buffer_len)) {
510+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
511+
RETVAL_FALSE;
512+
goto clean;
513+
}
509514

510515
wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC);
511516

ext/fileinfo/libmagic/softmagic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,9 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
10371037
if (bytecnt > nbytes) {
10381038
bytecnt = nbytes;
10391039
}
1040+
if (offset > bytecnt) {
1041+
offset = bytecnt;
1042+
}
10401043
if (s == NULL) {
10411044
ms->search.s_len = 0;
10421045
ms->search.s = NULL;

ext/fileinfo/tests/bug68819_001.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #68819 Fileinfo on specific file causes spurious OOM and/or segfault, var 1
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$string = <<<HERE
9+
----a-----'''---------a---------------a--------a-----a-----a---------a-----as-------a----a--a-------------a--as-----s---------------a---------a---a--s-a-----a-----------asy---------a-----a-----------a----s--------a-------------a-------a--------a----s------------a-----a----------------a----s-----------------\r\n-------------------a-------a-a-------a-----a----a----s----s--------a-----------------------a----a----s-------------a------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a----s----s--------a----------a----------------------a----a----s-------------a----------------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n------a-------a-a-------a-----a----a---a-----a-----------------------a----a---a-----a------------------s-------a----a---a-----a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s------\r\n-------------------a-------a-a-------a-----a----a---a-------a------------------------a----a---a-----''--a-------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a-------s-----a---a-------------------------a----a-------------a---a-------------------s-------a----a-------------a---a-----as-a--------------a-----a--s----s---------y------------a-----a-s---a-------''----a---s--a-''------''----s------------a-y----------------s------a-----y--a-s--a-s------s--a-s----------''----------------------------a---s--a----a---------a-s---a-s--------s--------a---------s--a-y-------------as----a----a-------------a------a---s--a-s------a--------a----s----y--as--a----a-s---------------a-----a--------------------------------------\r\n-------------------a-------a-a-------a-----a----a-----------s--------a-----------------------a----a--------------------a------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a-----------s--------a----------a----------------------a----a--------------------a------------------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a---a-----------------------a----a---a------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a---a----------a----------------------a----a---a------------------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-----a-a-----------a-------a-a-------a-----a----a----a---s-----a-----------------------a----a----a---------a-----------------s-------a----a----a---------a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a--------a----a-----------------------a----a----------a----a------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-----a-------------a-------a-a-------a-----a----a--------s-----a---a-------------------------a----a--------------a---a-------------------s-------------a---------------a----a---a---a-----as-a--------------a-----a--s----s---------y------------a-----a-s---a-------''----a---s--a-''------''----s------------a-y----------------s------a-----y--a-s--a-s------s--a-s----------''----------------------------a---s--a----a---------a-s---a-s--------s--------a---------s--a-y-------------as----a----a-------------a------a---s--a-s------a--------a----s----y--as--a----a-s---------------a-----a--------------------------------------\r\n-------------------a-------a-a-------a-----a----a----------------a-----------------------a----a----------------a------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a-------a-----a----a----------------a----------a----------------------a----a----------------a-----------------------------s-------a----a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n---a---------------a-------a-a-------a-----as------------------------a--a--s------------------a-s------------------------a-----s--a-----'''----------a-s---------------------------------------------a-----s--a-----------------a---------a---a--s-a-----a-----------asy---------a-----a-----------a----s----------------------a----s--a-------------a-------a--------a----s------------a-----a----------------a----s------------------\r\n-a-----------------a-------a-a-------a--y---------a------------------y---------a-----'''-------y------a-y--a-------------------------a---------a---a----------as-a---a--s-a-----a-----------asy---------a-----a-----------a----s--------a-------------a-------a--------a----s---------a-----a----------------a----s------------------\r\n-a-----------------a-------a-a-------a--y-------------a------------------y-------------a-----'''-------y----------a-y--a-------------------------a---------a---a----------as-a---a--s-a-----a-----------asy---------a-----a-----------a----s--------a-------------a-------a--------a----s---------a-----a----------------a----s------------------\r\n-------------------a-------a-a-------a--a----a-----a------------------a----a-----a-----'''----------a----s----a----a-------s---a------------------a-----------a--s-a-----a---------------------a------a----s-a-----a-------s-s-------a----s--------a-------------a-------a--------a----s---------a-----a----------------a----s------------------\r\n------aa-----------a-------a-a------------s-a--s---------a---a------------------------a------------a---a------------------s--------a------------a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a------------------------s-----s--a----a-----------------------------------------s--a----a------------------s---------------------------------s--a----a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s--------------a-----a----------a----------s--a----------s-----------------\r\n-------------------a-------a-a--------------s-a---a--------------------------a---a------------------s----------a---a------as---s-a--------------s-----a------a-y--a-------a-----a--a--------a----s--------a-------------a-------a--------a----s---------------a-----a----------a----------s--a----------s-----------------\r\nsay-------a------------s-----''------a----s--------a-------------a-\r\n
10+
HERE;
11+
12+
$finfo = new finfo();
13+
$type = $finfo->buffer($string);
14+
15+
var_dump($type);
16+
?>
17+
--EXPECT--
18+
string(60) "ASCII text, with very long lines, with CRLF line terminators"

ext/fileinfo/tests/bug68819_002.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #68819 Fileinfo on specific file causes spurious OOM and/or segfault, var 2
3+
--SKIPIF--
4+
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
$string = '';
9+
10+
// These two in any order
11+
$string .= "\r\n";
12+
$string .= "''''";
13+
14+
// Total string length > 8192
15+
$string .= str_repeat(chr(rand(32, 127)), 8184);
16+
17+
// Ending in this string
18+
$string .= "say";
19+
20+
$finfo = new finfo();
21+
$type = $finfo->buffer($string);
22+
var_dump($type);
23+
24+
?>
25+
--EXPECT--
26+
string(60) "ASCII text, with very long lines, with CRLF line terminators"

ext/fileinfo/tests/finfo_file_basic.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ echo "*** Testing finfo_file() : basic functionality ***\n";
1919
var_dump( finfo_file( $finfo, __FILE__) );
2020
var_dump( finfo_file( $finfo, __FILE__, FILEINFO_CONTINUE ) );
2121
var_dump( finfo_file( $finfo, $magicFile ) );
22+
var_dump( finfo_file( $finfo, $magicFile.chr(0).$magicFile) );
2223

2324
?>
2425
===DONE===
@@ -27,4 +28,7 @@ var_dump( finfo_file( $finfo, $magicFile ) );
2728
string(28) "text/x-php; charset=us-ascii"
2829
string(22) "PHP script, ASCII text"
2930
string(25) "text/plain; charset=utf-8"
31+
32+
Warning: finfo_file(): Invalid path in %s/finfo_file_basic.php on line %d
33+
bool(false)
3034
===DONE===

ext/gd/gd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ PHP_FUNCTION(imageloadfont)
14951495
gdFontPtr font;
14961496
php_stream *stream;
14971497

1498-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_name) == FAILURE) {
1498+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_name) == FAILURE) {
14991499
return;
15001500
}
15011501

@@ -2438,15 +2438,15 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
24382438
long ignore_warning;
24392439
#endif
24402440
if (image_type == PHP_GDIMG_TYPE_GD2PART) {
2441-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
2441+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
24422442
return;
24432443
}
24442444
if (width < 1 || height < 1) {
24452445
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Zero width or height not allowed");
24462446
RETURN_FALSE;
24472447
}
24482448
} else {
2449-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
2449+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
24502450
return;
24512451
}
24522452
}
@@ -4178,7 +4178,7 @@ PHP_FUNCTION(imagepsencodefont)
41784178
char *enc, **enc_vector;
41794179
int enc_len, *f_ind;
41804180

4181-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &fnt, &enc, &enc_len) == FAILURE) {
4181+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &fnt, &enc, &enc_len) == FAILURE) {
41824182
return;
41834183
}
41844184

ext/gd/tests/imageloadfont_error1.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ Testing that imageloadfont() breaks on non-string first parameter
33
--CREDITS--
44
Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
55
--SKIPIF--
6-
<?php
6+
<?php
77
if (!extension_loaded("gd")) die("skip GD not present");
88
?>
99
--FILE--
1010
<?php
1111
var_dump( imageloadfont(array()) );
1212
?>
1313
--EXPECTF--
14-
Warning: imageloadfont() expects parameter 1 to be string, array given in %s on line %d
15-
NULL
14+
Warning: imageloadfont() expects parameter 1 to be a valid path, array given in %s on line %d
15+
NULL

ext/hash/hash.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
142142
}
143143
if (isfilename) {
144144
if (CHECK_NULL_PATH(data, data_len)) {
145+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
145146
RETURN_FALSE;
146147
}
147148
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
@@ -222,6 +223,10 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
222223
RETURN_FALSE;
223224
}
224225
if (isfilename) {
226+
if (CHECK_NULL_PATH(data, data_len)) {
227+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
228+
RETURN_FALSE;
229+
}
225230
stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
226231
if (!stream) {
227232
/* Stream will report errors opening file */
@@ -449,7 +454,7 @@ PHP_FUNCTION(hash_update_file)
449454
char *filename, buf[1024];
450455
int filename_len, n;
451456

452-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
457+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
453458
return;
454459
}
455460

0 commit comments

Comments
 (0)