diff --git a/ext/standard/image.c b/ext/standard/image.c index 73e1776a3a2..5c87c9a49aa 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 00000000000..92e93e59e53 --- /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-- + +--EXPECTF-- +Warning: getimagesize(): Invalid path in %s on line %d +NULL