opnsense-src/usr.bin/diff
Dag-Erling Smørgrav ea68175b07 diff: Fix integer overflow.
The legacy Stone algorithm uses `int` to represent line numbers, array
indices, and array lengths.  If given inputs approaching `INT_MAX` lines,
it would overflow and attempt to allocate ridiculously large amounts of
memory.  To avoid this without penalizing non-pathological inputs,
switch a few variables to `size_t` and add checks while and immediately
after reading both inputs.

MFC after:	3 days
PR:		280371
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D46169

(cherry picked from commit 9317242469f1ca682626d9806f8caf65d143c09a)
2024-08-01 18:15:57 +02:00
..
tests diff: honour -B flag with -q 2024-05-24 19:59:11 -04:00
diff.1 diff: Fix usage message and documentation. 2024-08-01 18:15:57 +02:00
diff.c diff: Fix usage message and documentation. 2024-08-01 18:15:57 +02:00
diff.h Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:23 -06:00
diffdir.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
diffreg.c diff: Fix integer overflow. 2024-08-01 18:15:57 +02:00
Makefile Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
pr.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
pr.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
TODO Update diff(1) TODO removing what has been implemented 2020-02-07 10:18:01 +00:00
xmalloc.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
xmalloc.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00