vim/src/xxd
sendittothenewts 6e6aff0f7a
patch 9.1.0912: xxd: integer overflow with sparse files and -autoskip
Problem:  xxd: integer overflow with sparse files and -autoskip
Solution: reset zero_seen when at the limit, change the type to char
          (sendittothenewts)

When encountering INT_MAX lines of zeros in the input, xxd overflows an
`int` counter, resulting in undefined behaviour.  Usually, this results
in a spurious line of zeros being output every 2**32 lines, while the
"*" line is lost, as is the final line of zeros that delineate the file
size if at end of file.

Since xxd doesn't need to know exactly how many lines are being skipped
when it's > 3, the exact value of the line counter `zero_seen` doesn't
matter and it can simply be reduced in value before the overflow occurs.

Changing the type of `zero_seen` to `signed char` is not important, and
done only to make the bug triggerable with more modest file sizes, and
therefore more convenient to test the fix.

fixes: #16170
closes: #16175

Signed-off-by: sendittothenewts <ross.axe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-12-07 16:27:22 +01:00
..
Make_amiga.mak
Make_ming.mak patch 9.1.0623: Mingw: errors when trying to delete non-existing files 2024-07-26 19:07:48 +02:00
Make_mvc.mak patch 9.1.0530: xxd: MSVC warning about non-ASCII character 2024-07-04 19:35:48 +02:00
Make_vms.mms
Makefile patch 9.1.0846: debug symbols for xxd are not cleaned in Makefile 2024-11-07 22:11:06 +01:00
xxd.c patch 9.1.0912: xxd: integer overflow with sparse files and -autoskip 2024-12-07 16:27:22 +01:00