Fixed possible integer overflow in str_repeat().

This commit is contained in:
Ilia Alshanetsky 2003-04-02 00:25:45 +00:00
parent dcf0c70950
commit aab9718253

View File

@ -3787,6 +3787,10 @@ PHP_FUNCTION(str_repeat)
/* Initialize the result string */
result_len = Z_STRLEN_PP(input_str) * Z_LVAL_PP(mult);
if (result_len < 1 || result_len > 2147483647) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "You may not create strings longer then 2147483647 bytes");
RETURN_FALSE;
}
result = (char *)emalloc(result_len + 1);
/* Heavy optimization for situations where input string is 1 byte long */