{
zval **haystack, **needle;
char *found = NULL;
+ long found_offset;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack, &needle) ==
FAILURE) {
}
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;
}
--- /dev/null
+--TEST--
+Test whether strstr() and strrchr() are binary safe.
+--POST--
+--GET--
+--FILE--
+<?php
+$s = "alabala nica".chr(0)."turska panica";
+var_dump(strlen(strstr($s, "nic")));
+var_dump(strlen(strrchr($s," nic")));
+?>
+--EXPECT--
+int(18)
+int(19)
\ No newline at end of file