summaryrefslogtreecommitdiff
path: root/common/packet.c
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>2000-10-14 07:56:59 +0000
committerTed Lemon <source@isc.org>2000-10-14 07:56:59 +0000
commitda9a43af691aed258397508f54f867420953a65d (patch)
treeefb68dbb21215833e4c60bd0f0f7cffdfc5a3382 /common/packet.c
parentf606b1ce86f80bef5cc4c2017a94d730aa9cd36c (diff)
downloadisc-dhcp-da9a43af691aed258397508f54f867420953a65d.tar.gz
Fix a stupid byte-swap error.
Diffstat (limited to 'common/packet.c')
-rw-r--r--common/packet.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/common/packet.c b/common/packet.c
index 9ed7517e..28bea1be 100644
--- a/common/packet.c
+++ b/common/packet.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.37 2000/10/13 18:54:56 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.38 2000/10/14 07:56:59 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -238,6 +238,7 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen)
static int udp_packets_length_checked;
static int udp_packets_length_overflow;
unsigned len;
+ unsigned ulen;
ip = (struct ip *)(buf + bufix);
udp = (struct udphdr *)(buf + bufix + ip_len);
@@ -252,9 +253,9 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen)
return -1;
#endif /* USERLAND_FILTER */
- if (udp -> uh_ulen < sizeof udp ||
- ((unsigned char *)udp) + udp -> uh_ulen > buf + buflen) {
- log_info ("bogus UDP packet length: %d\n", udp -> uh_ulen);
+ ulen = ntohs (udp -> uh_ulen);
+ if (ulen < sizeof udp || ((unsigned char *)udp) + ulen > buf + buflen) {
+ log_info ("bogus UDP packet length: %d", ulen);
return -1;
}
@@ -285,7 +286,7 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen)
if (!data) {
data = buf + bufix + ip_len + sizeof *udp;
- len = ntohs (udp -> uh_ulen) - sizeof *udp;
+ len = ulen - sizeof *udp;
++udp_packets_length_checked;
if (len + data > buf + bufix + buflen) {
++udp_packets_length_overflow;
@@ -318,8 +319,7 @@ ssize_t decode_udp_ip_header (interface, buf, bufix, from, data, buflen)
&ip -> ip_src,
2 * sizeof ip -> ip_src,
IPPROTO_UDP +
- (u_int32_t)
- ntohs (udp -> uh_ulen)))));
+ (u_int32_t)ulen))));
udp_packets_seen++;
if (usum && usum != sum) {