This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/4] Detect EOL on-the-fly in strstr, strcasestr and memmem.


Maxim Kuvyrkov <maxim@codesourcery.com> writes:

> The problem is in initialization phase of matching the needle when length of haystack is about the same as needle.  We match the needle from inside out, starting with some point inside the needle (aka needle[suffix]), match the right side first, then the left side.  If the haystack is short, then haystack[suffix] may turn out to be beyond the end of haystack, thus causing the bug.  Current implementation correctly detects any EOL after haystack[suffix] and the attached patch adds a check for EOL from haystack[0] to haystack[suffix].

s/EOL/EOS/

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]