Skip to content
Snippets Groups Projects
  • Austin Clements's avatar
    7443b964
    Fix missing NUL-terminator in grep · 7443b964
    Austin Clements authored
    Currently, grep read()s into a buffer and then uses the buffer as a
    string. Since there's no NUL-terminator, this can cause it to falsely
    identify line breaks and matches from leftover data on earlier lines
    and, if a line fills up the entire buffer, to read past the end of the
    buffer.
    
    Fix this by NUL-terminating any data returned by read().
    
    Thanks to Keiichi Watanabe for the report.
    7443b964
    History
    Fix missing NUL-terminator in grep
    Austin Clements authored
    Currently, grep read()s into a buffer and then uses the buffer as a
    string. Since there's no NUL-terminator, this can cause it to falsely
    identify line breaks and matches from leftover data on earlier lines
    and, if a line fills up the entire buffer, to read past the end of the
    buffer.
    
    Fix this by NUL-terminating any data returned by read().
    
    Thanks to Keiichi Watanabe for the report.