From: fenner Date: Mon, 22 Nov 1999 04:24:28 +0000 (+0000) Subject: Fix truncation check (the current check will claim that a packet X-Git-Tag: tcpdump-3.5.1~478 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/a2392b0db27bde1c138248468eac013f03271219 Fix truncation check (the current check will claim that a packet truncated on the boundary of a route is not truncated). --- diff --git a/print-rip.c b/print-rip.c index 719e119f..e66146bc 100644 --- a/print-rip.c +++ b/print-rip.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.39 1999-11-21 09:37:00 fenner Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-rip.c,v 1.40 1999-11-22 04:24:28 fenner Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -104,8 +104,10 @@ rip_print(const u_char *dat, u_int length) register int i, j, trunc; i = min(length, snapend - dat) - sizeof(*rp); - if (i < 0) + if (i < 0) { + printf(" [|rip]"); return; + } rp = (struct rip *)dat; switch (rp->rip_cmd) { @@ -120,7 +122,7 @@ rip_print(const u_char *dat, u_int length) printf(" rip-resp %d[%d]:", j, length); else printf(" rip-resp %d:", j); - trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i); + trunc = (i / sizeof(*ni)) != j; ni = (struct rip_netinfo *)(rp + 1); for (; (i -= sizeof(*ni)) >= 0; ++ni) rip_entry_print(rp->rip_vers, ni);