Teach bsdgrep(1) how to handle the special case of a pattern being terminated early with a NULL byte. We ignore these patterns, in line with how gnugrep(1) handles the same case.
PR: 202022
Differential D10102
bsdgrep(1): Handle special case of pattern being terminated early with a NULL byte kevans on Mar 22 2017, 8:43 PM. Authored by Tags None Referenced Files
Details
Teach bsdgrep(1) how to handle the special case of a pattern being terminated early with a NULL byte. We ignore these patterns, in line with how gnugrep(1) handles the same case. PR: 202022 Test kcwu@csie.org's original example, ensure no segfault and no matches.
Diff Detail
Event TimelineComment Actions Practically, when does this happen? Malicious/test inputs only? Also, what happens with a nul mid-line? Just the first part of the line is used, the second part discarded?
Comment Actions Yes, or it could be under the class of rm -rf /$empty problems -- the following produces a perfectly valid pattern file that does exactly what you expect, because getline(3) does the right thing: printf "BSD\0\nLicensing\0\n" > /tmp/pat grep -f /tmp/pat /COPYRIGHT It's a quick step from there to, in some case, printf "$empty\0\n" >> /tmp/pat in some loop to generate a series of expressions to test by. The only problem here is we hadn't taken into consideration what getline(3) does when it comes across a "\0\n" line, which is produce the tested-for above.
Correct.
|