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.
{
u_int caplength;
u_char s;
{
u_int caplength;
u_char s;
ndo->ndo_protocol = "ascii";
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
ndo->ndo_protocol = "ascii";
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
- if (length > caplength)
+ if (length > caplength) {
ND_PRINT("\n");
while (length > 0) {
s = GET_U_1(cp);
ND_PRINT("\n");
while (length > 0) {
s = GET_U_1(cp);
+ if (truncated)
+ nd_trunc_longjmp(ndo);
u_int i;
u_int s1, s2;
u_int nshorts;
u_int i;
u_int s1, s2;
u_int nshorts;
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
char asciistuff[ASCII_LINELENGTH+1], *asp;
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp;
char asciistuff[ASCII_LINELENGTH+1], *asp;
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
- if (length > caplength)
+ if (length > caplength) {
nshorts = length / sizeof(u_short);
i = 0;
hsp = hexstuff; asp = asciistuff;
nshorts = length / sizeof(u_short);
i = 0;
hsp = hexstuff; asp = asciistuff;
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
ident, oset, HEXDUMP_HEXSTUFF_PER_LINE,
hexstuff, asciistuff);
}
+ if (truncated)
+ nd_trunc_longjmp(ndo);
u_int caplength;
u_int i, s;
u_int nshorts;
u_int caplength;
u_int i, s;
u_int nshorts;
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0;
- if (length > caplength)
+ if (length > caplength) {
nshorts = length / sizeof(u_short);
i = 0;
while (nshorts != 0) {
nshorts = length / sizeof(u_short);
i = 0;
while (nshorts != 0) {
ND_PRINT("%s0x%04x: ", ident, oset);
ND_PRINT(" %02x", GET_U_1(cp));
}
ND_PRINT("%s0x%04x: ", ident, oset);
ND_PRINT(" %02x", GET_U_1(cp));
}
+ if (truncated)
+ nd_trunc_longjmp(ndo);
-/*
- * just for completeness
- */
-hex_print(netdissect_options *ndo,const char *ident, const u_char *cp, u_int length)
+hex_print(netdissect_options *ndo,
+ const char *ident, const u_char *cp, u_int length)
- hex_print_with_offset(ndo, ident, cp, length, 0);
+ hex_print_with_offset(ndo, ident, cp, length, 0);
2 05:27:12.808464432 CALM FAST; SrcNwref:48; DstNwref:48;
0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
2 05:27:12.808464432 CALM FAST; SrcNwref:48; DstNwref:48;
0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
0x0010: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000
- 0x0020: 3030 3030 3030 3030 3030 0000000000
+ 0x0020: 3030 3030 3030 3030 3030 0000000000 [|calm_fast]
SNPA (length: 0): <empty>, bad opts/li
3 12:03:12.1048576 Q.922, hdr-len 2, DLCI 0, Flags [DE, FECN], NLPID unknown (0x22), length 72482:
0x0000: 0082 1000 5542 5343 70a1 0200 0400 0000 ....UBSCp.......
SNPA (length: 0): <empty>, bad opts/li
3 12:03:12.1048576 Q.922, hdr-len 2, DLCI 0, Flags [DE, FECN], NLPID unknown (0x22), length 72482:
0x0000: 0082 1000 5542 5343 70a1 0200 0400 0000 ....UBSCp.......
1 22:26:23.800723 Q.922, invalid address
2 22:26:23.937975 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x11), length 41:
1 22:26:23.800723 Q.922, invalid address
2 22:26:23.937975 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x11), length 41:
+ 0x0000: 886b 68 .kh [|fr]
3 22:26:23.938313 Q.922, invalid address
4 22:26:23.939938 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x14), length 160:
3 22:26:23.938313 Q.922, invalid address
4 22:26:23.939938 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x14), length 160:
+ 0x0000: a530 b0 .0. [|fr]
5 22:26:23.940187 Q.922, invalid address
6 22:26:23.941938 UI 00! Q.922, hdr-len 4, DLCI 5801792, Flags [none], NLPID unknown (0x11), length 179:
5 22:26:23.940187 Q.922, invalid address
6 22:26:23.941938 UI 00! Q.922, hdr-len 4, DLCI 5801792, Flags [none], NLPID unknown (0x11), length 179:
+ 0x0000: 886b 68 .kh [|fr]
7 22:26:23.942187 Q.922, invalid address
8 22:26:23.944938 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x14), length 30:
7 22:26:23.942187 Q.922, invalid address
8 22:26:23.944938 UI 00! Q.922, hdr-len 4, DLCI 5769024, Flags [none], NLPID unknown (0x14), length 30:
+ 0x0000: a530 b0 .0. [|fr]
9 22:26:23.945312 Q.922, invalid address
10 22:26:23.946188 UI 00! Q.922, hdr-len 4, DLCI 1856, Flags [none], NLPID unknown (0x11), length 85:
9 22:26:23.945312 Q.922, invalid address
10 22:26:23.946188 UI 00! Q.922, hdr-len 4, DLCI 1856, Flags [none], NLPID unknown (0x11), length 85:
+ 0x0000: 886b 68 .kh [|fr]
11 22:26:23.946562 Q.922, invalid address
12 22:26:23.949189 Q.922, invalid address
13 22:26:23.949813 UI 00! Q.922, hdr-len 4, DLCI 526144, Flags [none], NLPID unknown (0x14), length 46:
11 22:26:23.946562 Q.922, invalid address
12 22:26:23.949189 Q.922, invalid address
13 22:26:23.949813 UI 00! Q.922, hdr-len 4, DLCI 526144, Flags [none], NLPID unknown (0x14), length 46:
+ 0x0000: a530 b0 .0. [|fr]
14 22:26:23.950187 Q.922, invalid address
15 22:26:24.634000 UI 2c! Pad! Q.922, hdr-len 2, DLCI 288, Flags [none], NLPID NULL (0x00), length 24:
14 22:26:23.950187 Q.922, invalid address
15 22:26:24.634000 UI 2c! Pad! Q.922, hdr-len 2, DLCI 288, Flags [none], NLPID NULL (0x00), length 24:
+ 0x0000: 1188 6b68 ..kh [|fr]
16 22:26:24.634098 Q.922, invalid address
17 22:26:24.634151 UI 2c! Pad! Q.933, CCITT, codeset 0 [|q.933]
16 22:26:24.634098 Q.922, invalid address
17 22:26:24.634151 UI 2c! Pad! Q.933, CCITT, codeset 0 [|q.933]