X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3152237177a9abc0bd5016e92fe997ca7d51665d..a890c4489fa1bcee9f455ee28d772bb1ccf590bf:/print-isoclns.c diff --git a/print-isoclns.c b/print-isoclns.c index dc1613ee..f8de7bce 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -2309,10 +2309,6 @@ isis_print(netdissect_options *ndo, length=pdu_len; } - if(length > ndo->ndo_snaplen) { - goto trunc; - } - ND_TCHECK(*header_lsp); ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x", isis_print_id(header_lsp->lsp_id, LSP_ID_LEN), @@ -3085,19 +3081,30 @@ osi_print_cksum(netdissect_options *ndo, { uint16_t calculated_checksum; - /* do not attempt to verify the checksum if it is zero */ - if (!checksum || checksum_offset > length) { + /* do not attempt to verify the checksum if it is zero, + * if the total length is nonsense, + * if the offset is nonsense, + * or the base pointer is not sane + */ + if (!checksum + || length > ndo->ndo_snaplen + || checksum_offset > ndo->ndo_snaplen + || checksum_offset > length) { ND_PRINT((ndo, "(unverified)")); } else { unsigned char *truncated = "trunc"; - //printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen); - //ND_TCHECK2(pptr, checksum_offset+length); +#if 0 + printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen); + ND_TCHECK2(pptr, checksum_offset+length); +#endif calculated_checksum = create_osi_cksum(pptr, checksum_offset, length); if (checksum == calculated_checksum) { ND_PRINT((ndo, " (correct)")); } else { truncated = "incorrect"; - //trunc: +#if 0 + trunc: +#endif ND_PRINT((ndo, " (%s should be 0x%04x)", truncated, calculated_checksum)); } }