#
c718f9fc |
|
01-Apr-2016 |
Rich Felker <dalias@aerifal.cx> |
fix read past end of haystack buffer for short needles in memmem the two/three/four byte memmem specializations are not prepared to handle haystacks shorter than the needle; they unconditionally read at least up to the needle length and subtract from the haystack length. if the haystack is shorter, the remaining haystack length underflows and produces an unbounded search which will eventually either crash or find a spurious match. the top-level memmem function attempted to avoid this case already by checking for haystack shorter than needle, but it failed to re-check after using memchr to remove the maximal prefix not containing the first byte of the needle.
|
#
cef0f289 |
|
18-Jun-2014 |
Rich Felker <dalias@aerifal.cx> |
fix incorrect comparison loop condition in memmem the logic for this loop was copied from null-terminated-string logic in strstr without properly adapting it to work with explicit lengths. presumably this error could result in false negatives (wrongly comparing past the end of the needle/haystack), false positives (stopping comparison early when the needle contains null bytes), and crashes (from runaway reads past the end of mapped memory).
|
#
476cd1d9 |
|
18-Apr-2014 |
Rich Felker <dalias@aerifal.cx> |
fix false negatives with periodic needles in strstr, wcsstr, and memmem in cases where the memorized match range from the right factor exceeded the length of the left factor, it was wrongly treated as a mismatch rather than a match. issue reported by Yves Bastide.
|
#
6fbdeff0 |
|
09-Apr-2014 |
Timo Teräs <timo.teras@iki.fi> |
fix search past the end of haystack in memmem to optimize the search, memchr is used to find the first occurrence of the first character of the needle in the haystack before switching to a search for the full needle. however, the number of characters skipped by this first step were not subtracted from the haystack length, causing memmem to search past the end of the haystack.
|
#
57174444 |
|
11-Dec-2013 |
Szabolcs Nagy <nsz@port70.net> |
include cleanups: remove unused headers and add feature test macros
|
#
c86f2974 |
|
15-Oct-2012 |
Rich Felker <dalias@aerifal.cx> |
add memmem function (gnu extension) based on strstr. passes gnulib tests and a few quick checks of my own.
|