mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
Making strstr() binary safe.
This commit is contained in:
parent
b2d93b67fc
commit
2092d80230
1 changed files with 3 additions and 1 deletions
|
@ -1360,6 +1360,7 @@ PHP_FUNCTION(strstr)
|
||||||
zval **haystack, **needle;
|
zval **haystack, **needle;
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
char needle_char[2];
|
char needle_char[2];
|
||||||
|
long found_offset;
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() != 2 ||
|
if (ZEND_NUM_ARGS() != 2 ||
|
||||||
zend_get_parameters_ex(2, &haystack, &needle) == FAILURE) {
|
zend_get_parameters_ex(2, &haystack, &needle) == FAILURE) {
|
||||||
|
@ -1387,7 +1388,8 @@ PHP_FUNCTION(strstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
if (found) {
|
||||||
RETURN_STRING(found, 1);
|
found_offset = found - Z_STRVAL_PP(haystack);
|
||||||
|
RETURN_STRINGL(found, Z_STRLEN_PP(haystack) - found_offset, 1);
|
||||||
} else {
|
} else {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue