]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Handle ICMP packets with IP header options correctly.
authorTed Lemon <source@isc.org>
Mon, 12 Jan 1998 01:00:42 +0000 (01:00 +0000)
committerTed Lemon <source@isc.org>
Mon, 12 Jan 1998 01:00:42 +0000 (01:00 +0000)
common/icmp.c

index 59082842652fecd05968ee5443e1ed7221262dea..c3c357c042b44a2e0140e9ab5190998462729e07 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: icmp.c,v 1.7 1997/06/04 20:59:40 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: icmp.c,v 1.8 1998/01/12 01:00:42 mellon Exp $ Copyright (c) 1997 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -135,10 +135,11 @@ void icmp_echoreply (protocol)
        struct protocol *protocol;
 {
        struct icmp *icfrom;
+       struct ip *ip;
        struct sockaddr_in from;
        unsigned char icbuf [1500];
        int status;
-       int len;
+       int len, hlen;
        struct iaddr ia;
        void (*handler) PROTO ((struct iaddr, u_int8_t *, int));
 
@@ -150,13 +151,17 @@ void icmp_echoreply (protocol)
                return;
        }
 
-       /* Probably not for us. */
-       if (status < (sizeof (struct ip)) + (sizeof *icfrom)) {
+       /* Find the IP header length... */
+       ip = (struct ip *)icbuf;
+       hlen = ip -> ip_hl << 2;
+
+       /* Short packet? */
+       if (status < hlen + (sizeof *icfrom)) {
                return;
        }
 
-       len = status - sizeof (struct ip);
-       icfrom = (struct icmp *)(icbuf + sizeof (struct ip));
+       len = status - hlen;
+       icfrom = (struct icmp *)(icbuf + hlen);
 
        /* Silently discard ICMP packets that aren't echoreplies. */
        if (icfrom -> icmp_type != ICMP_ECHOREPLY) {