]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
raw reads include IP header before icmp header, so we have to skip over it.
authorTed Lemon <source@isc.org>
Sat, 8 Mar 1997 00:22:01 +0000 (00:22 +0000)
committerTed Lemon <source@isc.org>
Sat, 8 Mar 1997 00:22:01 +0000 (00:22 +0000)
common/icmp.c

index 4af824e72fdfc47316315a80374b07ca8f9a230a..c43ea3fe633318c7cf954364893233b656e5cbe2 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: icmp.c,v 1.2 1997/03/06 07:27:32 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: icmp.c,v 1.3 1997/03/08 00:22:01 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -146,16 +146,18 @@ void icmp_echoreply (protocol)
                warn ("icmp_echoreply: %m");
                return;
        }
-       if (status < sizeof *icfrom) {
+       if (status < (sizeof (struct ip)) + (sizeof *icfrom)) {
                warn ("icmp_echoreply: short packet");
                return;
        }
 
-       icfrom = (struct icmp *)icbuf;
+       len = status - sizeof (struct ip);
+       icfrom = (struct icmp *)(icbuf + sizeof (struct ip));
 
        /* Silently discard ICMP packets that aren't echoreplies. */
-       if (icfrom -> icmp_type != ICMP_ECHOREPLY)
+       if (icfrom -> icmp_type != ICMP_ECHOREPLY) {
                return;
+       }
 
        /* If we were given a second-stage handler, call it. */
        if (protocol -> local) {
@@ -163,6 +165,6 @@ void icmp_echoreply (protocol)
                memcpy (ia.iabuf, &from.sin_addr, sizeof from.sin_addr);
                ia.len = sizeof from.sin_addr;
 
-               (*handler) (ia, icbuf, status);
+               (*handler) (ia, icbuf, len);
        }
 }