Improved length parameter validation

This commit is contained in:
Ilia Alshanetsky 2007-03-08 00:18:10 +00:00
parent 42ff70ede8
commit 8696c9bc89

View File

@ -4655,7 +4655,7 @@ PHP_FUNCTION(substr_count)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length should be greater than 0.");
RETURN_FALSE;
}
if ((p + Z_LVAL_PP(length)) > endp) {
if ((p + Z_LVAL_PP(length)) <= p || (p + Z_LVAL_PP(length)) > endp) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length value %ld exceeds string length.", Z_LVAL_PP(length));
RETURN_FALSE;
}