diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2007-06-06 22:04:05 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2007-06-06 22:04:05 +0000 |
commit | 717e94c67ab58ceacbba4e7ec17c13b64ffc7b91 (patch) | |
tree | 94e6f7cb743e0ab1b6b272c5c70397e7caabca72 | |
parent | 2041566a124b09a1912142fc246764cd1504db99 (diff) | |
download | php-git-717e94c67ab58ceacbba4e7ec17c13b64ffc7b91.tar.gz |
Added missing format validator to unpack() function
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/standard/pack.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/unpack.phpt | 11 |
3 files changed, 18 insertions, 0 deletions
@@ -13,6 +13,7 @@ PHP NEWS - Fixed size calculation in chunk_split() (Stas) - Fixed integer overlow in str[c]spn() (Stas) - Fixed UMR in money_format() (Stas, Ilia) +- Added missing format validator to unpack() function (Ilia) - Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory already exists). (Pierre) - Fixed bug #41608 (segfault on a weird code with objects and switch()). diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 15924dba04..1e7acac6e1 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -635,6 +635,12 @@ PHP_FUNCTION(unpack) case 'd': size = sizeof(double); break; + + default: + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid format type %c", type); + zval_dtor(return_value); + RETURN_FALSE; + break; } /* Do actual unpacking */ diff --git a/ext/standard/tests/strings/unpack.phpt b/ext/standard/tests/strings/unpack.phpt new file mode 100644 index 0000000000..f843dab878 --- /dev/null +++ b/ext/standard/tests/strings/unpack.phpt @@ -0,0 +1,11 @@ +--TEST-- +Invalid format type validation +--FILE-- +<?php + var_dump(unpack("-2222", 1)); + echo "Done\n"; +?> +--EXPECTF-- +Warning: unpack(): Invalid format type - in %s/unpack.php on line %d +bool(false) +Done
\ No newline at end of file |