]> The Tcpdump Group git mirrors - tcpdump/commit
ASCII/hex: Use nd_trunc_longjmp() in truncation cases
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 27 Mar 2021 15:14:27 +0000 (16:14 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 27 Mar 2021 19:54:29 +0000 (20:54 +0100)
commit5ee4e508deb94d0a8a0268cd72fd66dcfc680eb5
treee8ac30565f6d2a83dfcb2986be6c02c5f746f1c9
parent8281c4ae6e7e01524d20dd69b2275d0ed7949216
ASCII/hex: Use nd_trunc_longjmp() in truncation cases

In functions ascii_print(), hex_and_ascii_print_with_offset() and
hex_print_with_offset().
Therefore indirectly for the functions hex_and_ascii_print(), hex_print()
and ndo_default_print().

Even if hex_and_ascii_print(), hex_print() and ascii_print() are used in
print.c after the setjmp() block with the calls:

1) hex_and_ascii_print(ndo, "\n\t", sp, h->caplen);
2) hex_and_ascii_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen);
3) hex_print(ndo, "\n\t", sp, h->caplen);
4) hex_print(ndo, "\n\t", sp + hdrlen, h->caplen - hdrlen);
5) ascii_print(ndo, sp, h->caplen);
6) ascii_print(ndo, sp + hdrlen, h->caplen - hdrlen);

sp and h->caplen are unmodified, ndo->ndo_snapend was restored.

1), 3) and 5) the length to print is caplen => no truncation can occur.
2), 4) and 6) the length to print is (caplen - hdrlen) after a shift of
hdrlen => no truncation can occur.

Moreover:
Update the output of three tests accordingly.
Remove an useless comment.
Fix indentation.
print-ascii.c
tests/calm-fast-mac-lookup-heapoverflow.out
tests/esis_snpa_asan.out
tests/q933-heapoverflow-2.out