summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/standard/image.c5
-rw-r--r--ext/standard/tests/image/bug79877.phpt9
3 files changed, 16 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 10820bb391..3ac4dc80d8 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ PHP NEWS
to return usec). (Herbert256)
- Core:
+ . Fixed bug #79877 (getimagesize function silently truncates after a null
+ byte) (cmb)
. Fixed bug #79778 (Assertion failure if dumping closure with unresolved
static variable). (Nikita)
. Fixed bug #79792 (HT iterators not removed if empty array is destroyed).
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 2aafad9f2a..fc4d6bdc7b 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1496,6 +1496,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
Z_PARAM_ZVAL_DEREF(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) {
zval_ptr_dtor(info);
array_init(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