hexdump: Partial lines cannot be repetitions of earlier lines.
authorXin LI <delphij@FreeBSD.org>
Fri, 9 Jun 2023 01:38:47 +0000 (18:38 -0700)
committerXin LI <delphij@FreeBSD.org>
Fri, 9 Jun 2023 01:39:05 +0000 (18:39 -0700)
commitd1016568185ddacbf1148acbe26b27258981b4f0
tree40169d19c6e73808ee1a16a8f429818b13ccc554
parentcbbac560911521c0ded3e06e713107176855fae4
hexdump: Partial lines cannot be repetitions of earlier lines.

When checking for repetitions of earlier lines, we compare the
first nread bytes of the line against the saved line. However,
when we read a partial line, it should never be treated as a
repetition of an earlier line, even if the first bytes match.

This change fixes a bug where a partial line could be
incorrectly identified as a repetition of an earlier line.

Reported-by: Mark Adler <madler@alumni.caltech.edu>
PR: 118723
Reviewed-by: emaste
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D40471
usr.bin/hexdump/display.c
usr.bin/hexdump/tests/Makefile
usr.bin/hexdump/tests/d_hexdump_UCflag_bug118723.out [new file with mode: 0644]
usr.bin/hexdump/tests/d_hexdump_UCvflag_bug118723.out [new file with mode: 0644]
usr.bin/hexdump/tests/d_hexdump_bug118723.in [new file with mode: 0644]
usr.bin/hexdump/tests/hexdump_test.sh