summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2006-10-02 19:42:42 +0000
committerAndrei Zmievski <andrei@php.net>2006-10-02 19:42:42 +0000
commitc36d94aac251298cf78d37a52799cfed61ea7eea (patch)
treefcf4bdef3eb5a609be18e992f6c75dab284fe8fb /ext/standard
parent9c1b3c6d881fef417ab4eff0dde9655be9ed18d0 (diff)
downloadphp-git-c36d94aac251298cf78d37a52799cfed61ea7eea.tar.gz
Fix invalid memory access in strrpos().
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/string.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 4ce916715a..a59115765f 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1767,13 +1767,18 @@ PHP_FUNCTION(strrpos)
}
if (offset >= 0) {
+ if (offset > haystack_len) {
+ RETURN_FALSE;
+ }
p = haystack + offset;
e = haystack + haystack_len - needle_len;
} else {
- p = haystack;
if (-offset > haystack_len) {
- e = haystack - needle_len;
- } else if (needle_len > -offset) {
+ RETURN_FALSE;
+ }
+
+ p = haystack;
+ if (needle_len > -offset) {
e = haystack + haystack_len - needle_len;
} else {
e = haystack + haystack_len + offset;