diff options
author | Rich Felker <dalias@aerifal.cx> | 2016-04-01 13:36:15 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2016-04-01 13:36:15 -0400 |
commit | c718f9fc1b4bd913eff10d0c12763f90b2bc487c (patch) | |
tree | 7c34bd9ff1e852482c983b7755fbe47e97fb6bbb /include/getopt.h | |
parent | 5c3412d22555d03a1c00578ba8faaa8dc9206420 (diff) | |
download | musl-c718f9fc1b4bd913eff10d0c12763f90b2bc487c.tar.gz musl-c718f9fc1b4bd913eff10d0c12763f90b2bc487c.tar.xz musl-c718f9fc1b4bd913eff10d0c12763f90b2bc487c.zip |
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.
Diffstat (limited to 'include/getopt.h')
0 files changed, 0 insertions, 0 deletions