X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/44d21c36a135710261a1ae9733f12bf9ef9c2aa6..5ef0bcb5edd748de9d9af13c40da0395dfdd94e8:/util-print.c diff --git a/util-print.c b/util-print.c index c87e3265..e22e535e 100644 --- a/util-print.c +++ b/util-print.c @@ -473,17 +473,13 @@ void nd_print_invalid(netdissect_options *ndo) */ int -print_unknown_data(netdissect_options *ndo, const u_char *cp,const char *ident,int len) +print_unknown_data(netdissect_options *ndo, const u_char *cp, + const char *ident, u_int len) { u_int len_to_print; - if (len < 0) { - ND_PRINT("%sDissector error: print_unknown_data called with negative length", - ident); - return(0); - } len_to_print = len; - if (ndo->ndo_snapend < cp) { + if (!ND_TTEST_LEN(cp, 0)) { ND_PRINT("%sDissector error: print_unknown_data called with pointer past end of packet", ident); return(0); @@ -782,7 +778,6 @@ print_txt_line(netdissect_options *ndo, const char *prefix, startidx = idx; while (idx < len) { - ND_TCHECK_1(pptr + idx); c = GET_U_1(pptr + idx); if (c == '\n') { /* @@ -799,7 +794,6 @@ print_txt_line(netdissect_options *ndo, const char *prefix, /* not in this packet */ return (0); } - ND_TCHECK_1(pptr + idx + 1); if (GET_U_1(pptr + idx + 1) == '\n') { /* * CR-LF; end of line. @@ -832,7 +826,6 @@ print_txt_line(netdissect_options *ndo, const char *prefix, * All printable ASCII, but no line ending after that point * in the buffer; treat this as if it were truncated. */ -trunc: linelen = idx - startidx; ND_PRINT("%s%.*s", prefix, (int)linelen, pptr + startidx); nd_print_trunc(ndo);