From 717e94c67ab58ceacbba4e7ec17c13b64ffc7b91 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 6 Jun 2007 22:04:05 +0000 Subject: [PATCH] Added missing format validator to unpack() function --- NEWS | 1 + ext/standard/pack.c | 6 ++++++ ext/standard/tests/strings/unpack.phpt | 11 +++++++++++ 3 files changed, 18 insertions(+) create mode 100644 ext/standard/tests/strings/unpack.phpt diff --git a/NEWS b/NEWS index 278fdd153e..e74192367c 100644 --- a/NEWS +++ b/NEWS @@ -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-- + +--EXPECTF-- +Warning: unpack(): Invalid format type - in %s/unpack.php on line %d +bool(false) +Done \ No newline at end of file -- 2.50.1