com php-src: Fix #79877: getimagesize function silently truncates after a null byte: ext/standard/image.c ext/standard/tests/image/bug79877.phpt

From: Date: Mon, 03 Aug 2020 08:10:24 +0000
Subject: com php-src: Fix #79877: getimagesize function silently truncates after a null byte: ext/standard/image.c ext/standard/tests/image/bug79877.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112498@lists.php.net to get a copy of this message
Commit: 05c5c9370537ff2fc8d37629beb6ae8e354500c8 Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 21 Jul 2020 11:07:43 +0200 Committer: Stanislav Malyshev <stas@php.net> Mon, 3 Aug 2020 01:10:24 -0700 Parents: 775385df0e954f8cf9b5046bebc8e40ce26e601b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=05c5c9370537ff2fc8d37629beb6ae8e354500c8 Log: Fix #79877: getimagesize function silently truncates after a null byte We have to check for NUL bytes if getimagesize() has been called. Bugs: https://bugs.php..net/79877 Changed paths: M ext/standard/image.c A ext/standard/tests/image/bug79877.phpt Diff: diff --git a/ext/standard/image.c b/ext/standard/image.c index 73e1776a3a..5c87c9a49a 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1475,6 +1475,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) { Z_PARAM_ZVAL(info) ZEND_PARSE_PARAMETERS_END(); + if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) { + php_error_docref(NULL, E_WARNING, "Invalid path"); + return; + } + if (argc == 2) { info = zend_try_array_init(info); if (!info) { diff --git a/ext/standard/tests/image/bug79877.phpt b/ext/standard/tests/image/bug79877.phpt new file mode 100644 index 0000000000..92e93e59e5 --- /dev/null +++ b/ext/standard/tests/image/bug79877.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #79877 (getimagesize function silently truncates after a null byte) +--FILE-- +<?php +var_dump(getimagesize("/tmp/a.png\0xx")); +?> +--EXPECTF-- +Warning: getimagesize(): Invalid path in %s on line %d +NULL

« previous php.cvs (#112498) next »