diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2011-03-03 00:30:32 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2011-03-03 00:30:32 +0000 |
commit | 39b020e742dfb1597fb501ba5f2d86287ff66b20 (patch) | |
tree | 98a4061b25e96b5eb4e28d96212de08cd7eedd2f /sbin | |
parent | eef3705d3d96a1fd21de41a2b2d36c88f2ba04a8 (diff) |
This change makes ping compare minimum amount of bytes between what
was received and what was sent out and print additional information
explaining payload size differences.
Issue was found by reyk, debugged by jsg and me with an input from
claudio (who found out that initial version breaks -w) and bluhm
(who advised to notify a user). Ok bluhm and deraadt on the
previous version of the diff. Lots of history for a one-liner :)
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ping6/ping6.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 92827d27f72..36516c8ddc7 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping6.c,v 1.80 2010/06/26 18:30:03 phessler Exp $ */ +/* $OpenBSD: ping6.c,v 1.81 2011/03/03 00:30:31 mikeb Exp $ */ /* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */ /* @@ -1359,6 +1359,13 @@ pr_pack(u_char *buf, int cc, struct msghdr *mhdr) /* check the data */ cp = buf + off + ICMP6ECHOLEN + ICMP6ECHOTMLEN; dp = outpack + ICMP6ECHOLEN + ICMP6ECHOTMLEN; + if (cc != ICMP6ECHOLEN + datalen) { + int delta = cc - (datalen + ICMP6ECHOLEN); + + (void)printf(" (%d bytes %s)", + abs(delta), delta > 0 ? "extra" : "short"); + end = buf + MIN(cc, ICMP6ECHOLEN + datalen); + } for (i = 8; cp < end; ++i, ++cp, ++dp) { if (*cp != *dp) { (void)printf("\nwrong data byte #%d should be 0x%x but was 0x%x", i, *dp, *cp); |