summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/phar/tests/bug79797.pharbin0 -> 274 bytes
-rw-r--r--ext/phar/tests/bug79797.phpt14
-rw-r--r--ext/phar/zip.c2
-rw-r--r--ext/standard/image.c5
-rw-r--r--ext/standard/tests/image/bug79877.phpt9
5 files changed, 29 insertions, 1 deletions
diff --git a/ext/phar/tests/bug79797.phar b/ext/phar/tests/bug79797.phar
new file mode 100644
index 0000000000..21d43d9eeb
--- /dev/null
+++ b/ext/phar/tests/bug79797.phar
Binary files differ
diff --git a/ext/phar/tests/bug79797.phpt b/ext/phar/tests/bug79797.phpt
new file mode 100644
index 0000000000..761e5379e0
--- /dev/null
+++ b/ext/phar/tests/bug79797.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #79797 (Use of freed hash key in the phar_parse_zipfile function)
+--SKIPIF--
+<?php
+if (!extension_loaded('phar')) die('skip phar extension not available');
+?>
+--INI--
+phar.cache_list={PWD}/bug79797.phar
+--FILE--
+<?php
+echo "done\n";
+?>
+--EXPECT--
+done
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 9c9e3f6d68..4bed35f636 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -705,7 +705,7 @@ foundit:
efree(actual_alias);
}
- zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
+ zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata);
} else {
phar_archive_data *fd_ptr;
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