diff options
author | pjd <pjd@FreeBSD.org> | 2005-02-11 21:07:51 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-02-11 21:07:51 +0000 |
commit | 6ce8df8f98762bd02122e50bfd15d016a10b64a5 (patch) | |
tree | 1aa5eb32696721df33cf66a652d0bc8783a83d2b /lib/libc/string/strnstr.c | |
parent | 4712983b229e6e5b875e0085a2e78e05cf3146a4 (diff) | |
download | FreeBSD-src-6ce8df8f98762bd02122e50bfd15d016a10b64a5.zip FreeBSD-src-6ce8df8f98762bd02122e50bfd15d016a10b64a5.tar.gz |
Don't read more than the given 'len' bytes from the 'big' string.
PR: misc/77369
Submitted by: Ed Maste <emaste@phaedrus.sandvine.ca>
MFC after: 1 week
Diffstat (limited to 'lib/libc/string/strnstr.c')
-rw-r--r-- | lib/libc/string/strnstr.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/string/strnstr.c b/lib/libc/string/strnstr.c index 6983507..749c43b 100644 --- a/lib/libc/string/strnstr.c +++ b/lib/libc/string/strnstr.c @@ -60,7 +60,7 @@ strnstr(s, find, slen) len = strlen(find); do { do { - if ((sc = *s++) == '\0' || slen-- < 1) + if (slen-- < 1 || (sc = *s++) == '\0') return (NULL); } while (sc != c); if (len > slen) |