diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/pack.c | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/unpack.phpt | 11 |
2 files changed, 17 insertions, 0 deletions
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 |