mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
printf: Report error if missing padding character
This commit is contained in:
parent
0b99017516
commit
30a5f3da99
2 changed files with 16 additions and 6 deletions
|
@ -470,10 +470,16 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
|
|||
/* space padding, the default */
|
||||
} else if (*format == '+') {
|
||||
always_sign = 1;
|
||||
} else if (*format == '\'' && format_len > 1) {
|
||||
format++;
|
||||
format_len--;
|
||||
padding = *format;
|
||||
} else if (*format == '\'') {
|
||||
if (format_len > 1) {
|
||||
format++;
|
||||
format_len--;
|
||||
padding = *format;
|
||||
} else {
|
||||
zend_value_error("Missing padding character");
|
||||
zend_string_efree(result);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
PRINTF_DEBUG(("sprintf: end of modifiers\n"));
|
||||
break;
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
Bug #67249 (printf out-of-bounds read)
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(sprintf("%'", "foo"));
|
||||
try {
|
||||
var_dump(sprintf("%'", "foo"));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
string(0) ""
|
||||
Missing padding character
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue