tre-agrep can print garbage instead of delimiter
Opened this issue · 0 comments
Deleted user commented
When --delimiter (-d) is specified, and delimiter is to be printed before the matching record, tre-grep can print delim_len
bytes of garbage, instead of the delimiter. This is because, just before printing the matching record, an adjustment is made to |record|, the start of the current record. delim_len
is subtracted from record
, it is not necessarily true that there are that many bytes in the buffer, buf
, between buf
and record
. So, whatever bytes are just below buf
get printed. My experience, so far, is that it just prints garbage, but the behavior is undefined, so it could be worse.
My test version has a test to ensure that record - buf >= delim_len
.