andrey Wed Oct 2 14:58:10 2002 EDT
Added files:
/php4/ext/standard/tests/strings 002.phpt
Modified files:
/php4/ext/standard string.c
Log:
Making strrchr() binary safe.
Test case added.
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.303 php4/ext/standard/string.c:1.304
--- php4/ext/standard/string.c:1.303 Wed Oct 2 14:41:55 2002
+++ php4/ext/standard/string.c Wed Oct 2 14:58:09 2002
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.303 2002/10/02 18:41:55 andrey Exp $ */
+/* $Id: string.c,v 1.304 2002/10/02 18:58:09 andrey Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -1487,6 +1487,7 @@
{
zval **haystack, **needle;
char *found = NULL;
+ long found_offset;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &haystack, &needle) ==
FAILURE) {
@@ -1503,7 +1504,8 @@
}
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;
}
Index: php4/ext/standard/tests/strings/002.phpt
+++ php4/ext/standard/tests/strings/002.phpt
--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)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php