X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/ebc144f368850175fd63b23295ad275f7b001a4f..27cb3953154b4562a7f4b51be6146688531903bd:/print-lwres.c diff --git a/print-lwres.c b/print-lwres.c index abc6fbe3..aad4eee3 100644 --- a/print-lwres.c +++ b/print-lwres.c @@ -28,8 +28,8 @@ */ #ifndef lint -static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.10 2003-07-30 20:34:58 guy Exp $ (LBL)"; +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-lwres.c,v 1.13 2004-03-24 01:54:29 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -265,16 +265,19 @@ lwres_printaddr(lwres_addr_t *ap) l = EXTRACT_16BITS(&ap->length); /* XXX ap points to packed struct */ p = (const char *)&ap->length + sizeof(ap->length); - if (p + l > (const char *)snapend) - goto trunc; + TCHECK2(*p, l); switch (EXTRACT_32BITS(&ap->family)) { case 1: /* IPv4 */ + if (l < 4) + return -1; printf(" %s", ipaddr_string(p)); p += sizeof(struct in_addr); break; #ifdef INET6 case 2: /* IPv6 */ + if (l < 16) + return -1; printf(" %s", ip6addr_string(p)); p += sizeof(struct in6_addr); break;