mirror of
https://github.com/php/php-src.git
synced 2025-01-27 06:03:45 +08:00
MFB: Added missing format validator to unpack() function
This commit is contained in:
parent
6a67784d22
commit
60a7d31254
@ -613,6 +613,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 */
|
||||
|
11
ext/standard/tests/strings/unpack.phpt
Normal file
11
ext/standard/tests/strings/unpack.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user