From: Guy Harris Date: Tue, 18 Aug 2009 21:47:13 +0000 (-0700) Subject: Check that bytes exist in the captured data before fetching them. X-Git-Tag: tcpdump-4.1.0~75 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/9da2a96bb5e968223e19bf0a6342d1b9ada1efbc Check that bytes exist in the captured data before fetching them. --- diff --git a/print-sip.c b/print-sip.c index 48562f8c..c5bc8534 100644 --- a/print-sip.c +++ b/print-sip.c @@ -44,6 +44,7 @@ sip_print(register const u_char *pptr, register u_int len) return; for (idx = 0; idx < len; idx++) { + TCHECK2(*(pptr+idx), 2); if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */ safeputchar(*(pptr+idx)); } else { @@ -57,4 +58,7 @@ sip_print(register const u_char *pptr, register u_int len) print_unknown_data(pptr,"\n\t",len); return; + +trunc: + printf("[|sip]"); }