summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2007-02-15 18:23:15 +0000
committerwtchang%redhat.com <devnull@localhost>2007-02-15 18:23:15 +0000
commit20a1a76f43e83804458b2b8e2ee54f67421e9be4 (patch)
tree87c4fec9e1678597cc5bf57c3de21e2df963af57
parente7fda08c9d96fa9defd1875b227013a60de0f8b3 (diff)
downloadnspr-hg-20a1a76f43e83804458b2b8e2ee54f67421e9be4.tar.gz
Bug 369467: use a more robust way to ensure the pointer p does not point
before the array big. The patch is contributed by Wolfgang Rosenauer <mozilla@rosenauer.org>. r=wtc
-rw-r--r--lib/libc/src/strcstr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/src/strcstr.c b/lib/libc/src/strcstr.c
index cb587788..33421270 100644
--- a/lib/libc/src/strcstr.c
+++ b/lib/libc/src/strcstr.c
@@ -59,14 +59,15 @@ PR_IMPLEMENT(char *)
PL_strcaserstr(const char *big, const char *little)
{
const char *p;
- PRUint32 ll;
+ PRUint32 bl, ll;
if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0;
if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0;
+ bl = PL_strlen(big);
ll = PL_strlen(little);
- p = &big[ PL_strlen(big) - ll ];
- if( p < big ) return (char *)0;
+ if( bl < ll ) return (char *)0;
+ p = &big[ bl - ll ];
for( ; p >= big; p-- )
/* obvious improvement available here */