From: Stanislav Malyshev Date: Tue, 5 Aug 2008 20:11:17 +0000 (+0000) Subject: fix memnstr bug, by Laurent Gaffie X-Git-Tag: php-5.2.7RC1~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adf6be4bfbd6f7c7b3fee16c54dbff50a8db59c3;p=php fix memnstr bug, by Laurent Gaffie --- diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 2fa4097ec2..03a4ed35d4 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -220,6 +220,9 @@ zend_memnstr(char *haystack, char *needle, int needle_len, char *end) char *p = haystack; char ne = needle[needle_len-1]; + if(needle_len > end-haystack) { + return NULL; + } end -= needle_len; while (p <= end) { diff --git a/ext/standard/tests/strings/explode_bug.phpt b/ext/standard/tests/strings/explode_bug.phpt new file mode 100644 index 0000000000..9766f0b8f4 --- /dev/null +++ b/ext/standard/tests/strings/explode_bug.phpt @@ -0,0 +1,15 @@ +--TEST-- +Explode/memnstr bug +--INI-- +error_reporting=2047 +memory_limit=256M +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + string(1) "1" +}