summaryrefslogtreecommitdiff
path: root/common/nit.c
diff options
context:
space:
mode:
authorEvan Hunt <each@isc.org>2007-04-27 23:54:06 +0000
committerEvan Hunt <each@isc.org>2007-04-27 23:54:06 +0000
commit83c0372e288d764944bf6bb4b78fb4e95159b52e (patch)
treeb576cdcd4821049217ae044f7d0e5258fbc45aab /common/nit.c
parent46153375b006bf72b3bb7c7b097ff32f0ccd1427 (diff)
downloadisc-dhcp-83c0372e288d764944bf6bb4b78fb4e95159b52e.tar.gz
Assorted fixes for broken network devices: IP header length field is now
determined from payload, because some NIC drivers return more data than they actually recived; IP and UDP packets now stored in aligned data structures; outgoing packet TTL increased from 16 to 128. [rt15583]
Diffstat (limited to 'common/nit.c')
-rw-r--r--common/nit.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/common/nit.c b/common/nit.c
index 4fc1fb6d..26549412 100644
--- a/common/nit.c
+++ b/common/nit.c
@@ -35,7 +35,7 @@
#ifndef lint
static char copyright[] =
-"$Id: nit.c,v 1.35 2005/03/17 20:14:59 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
+"$Id: nit.c,v 1.36 2007/04/27 23:54:05 each Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -350,6 +350,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
int offset = 0;
unsigned char ibuf [1536];
int bufix = 0;
+ unsigned paylen;
length = read (interface -> rfdesc, ibuf, sizeof ibuf);
if (length <= 0)
@@ -370,7 +371,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/* Decode the IP and UDP headers... */
offset = decode_udp_ip_header (interface, ibuf, bufix,
- from, length);
+ from, length, &paylen);
/* If the IP or UDP checksum was bad, skip the packet... */
if (offset < 0)
@@ -379,9 +380,12 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
bufix += offset;
length -= offset;
+ if (length < paylen)
+ log_fatal("Internal inconsistency at %s:%d.", MDL);
+
/* Copy out the data in the packet... */
- memcpy (buf, &ibuf [bufix], length);
- return length;
+ memcpy(buf, &ibuf[bufix], paylen);
+ return paylen;
}
int can_unicast_without_arp (ip)