diff options
author | Antony Dovgal <tony2001@php.net> | 2006-10-04 11:14:32 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2006-10-04 11:14:32 +0000 |
commit | d8648eae57547a1e70461a1089e982eaa10a932f (patch) | |
tree | 98f02a28c4eb2cf8000f31c61b4376bd67b55b38 | |
parent | f72c1a12249fa08fe8436aece464f8392cf16963 (diff) | |
download | php-git-d8648eae57547a1e70461a1089e982eaa10a932f.tar.gz |
MFH: fix #39032 (strcspn() stops on null character)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | ext/standard/string.c | 2 | ||||
-rw-r--r-- | ext/standard/tests/strings/bug39032.phpt | 18 |
3 files changed, 20 insertions, 1 deletions
@@ -7,6 +7,7 @@ PHP NEWS - Fixed mess with CGI/CLI -d option (now it works with cgi; constants are working exactly like in php.ini; with FastCGI -d affects all requests). (Dmitry) +- Fixed bug #39032 (strcspn() stops on null character). (Tony) - Fixed bug #39017 (foreach(($obj = new myClass) as $v); echo $obj; segfaults). (Dmitry) - Fixed bug #39004 (Fixed generation of config.nice with autoconf 2.60). diff --git a/ext/standard/string.c b/ext/standard/string.c index ee1cdbb845..759528a232 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1500,7 +1500,7 @@ PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end) if (*spanp == c || p == s1_end) { return p - s1; } - } while (spanp++ < s2_end); + } while (spanp++ < (s2_end - 1)); c = *++p; } /* NOTREACHED */ diff --git a/ext/standard/tests/strings/bug39032.phpt b/ext/standard/tests/strings/bug39032.phpt new file mode 100644 index 0000000000..dbd39ec9d8 --- /dev/null +++ b/ext/standard/tests/strings/bug39032.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39032 (strcspn() stops on null character) +--FILE-- +<?php + +var_dump(strcspn(chr(0),"x")); +var_dump(strcspn(chr(0),"")); +var_dump(strcspn(chr(0),"qweqwe")); +var_dump(strcspn(chr(1),"qweqwe")); + +echo "Done\n"; +?> +--EXPECTF-- +int(1) +int(0) +int(1) +int(1) +Done |