diff options
author | Andrey Hristov <andrey@php.net> | 2002-10-02 18:41:55 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2002-10-02 18:41:55 +0000 |
commit | 2092d80230a1327e3796bcc4e405667f4da3f459 (patch) | |
tree | 3513a915995c12441ce0ae2b691c582b80dbd622 /ext/standard/string.c | |
parent | b2d93b67fc26b5dbba0d444107ef84eb6409c6e6 (diff) | |
download | php-git-2092d80230a1327e3796bcc4e405667f4da3f459.tar.gz |
Making strstr() binary safe.
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r-- | ext/standard/string.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c index a5dff3ed8f..540908db96 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1360,6 +1360,7 @@ PHP_FUNCTION(strstr) zval **haystack, **needle; char *found = NULL; char needle_char[2]; + long found_offset; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack, &needle) == FAILURE) { @@ -1387,7 +1388,8 @@ PHP_FUNCTION(strstr) } if (found) { - RETURN_STRING(found, 1); + found_offset = found - Z_STRVAL_PP(haystack); + RETURN_STRINGL(found, Z_STRLEN_PP(haystack) - found_offset, 1); } else { RETURN_FALSE; } |