diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-03 21:04:20 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-02-03 21:04:20 +0000 |
commit | 72301ba7fd9bf54a0e97bf36d1daff73a584e39a (patch) | |
tree | abcb9cd95642331de5eebe6b8df74630b1d80688 /usr.sbin | |
parent | c068c6e6ad0e5e1af7a6eadc85ccd05c0e38f309 (diff) |
Remove unused (a.k.a. always passed NULL) parameter 'data' from
decode_udp_ip_header() and the useless check of it. Part of original
diff from pelikan about udp length errors.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/dhcpd/bpf.c | 4 | ||||
-rw-r--r-- | usr.sbin/dhcpd/dhcpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/dhcpd/packet.c | 43 |
3 files changed, 25 insertions, 26 deletions
diff --git a/usr.sbin/dhcpd/bpf.c b/usr.sbin/dhcpd/bpf.c index efa3fcff140..a17147d03e3 100644 --- a/usr.sbin/dhcpd/bpf.c +++ b/usr.sbin/dhcpd/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.8 2009/12/14 22:12:14 mpf Exp $ */ +/* $OpenBSD: bpf.c,v 1.9 2013/02/03 21:04:19 krw Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -341,7 +341,7 @@ receive_packet(struct interface_info *interface, unsigned char *buf, /* Decode the IP and UDP headers... */ offset = decode_udp_ip_header(interface, interface->rbuf, - interface->rbuf_offset, from, NULL, hdr.bh_caplen); + interface->rbuf_offset, from, hdr.bh_caplen); /* If the IP or UDP checksum was bad, skip the packet... */ if (offset < 0) { diff --git a/usr.sbin/dhcpd/dhcpd.h b/usr.sbin/dhcpd/dhcpd.h index 075d8222ad0..125e71fbfb2 100644 --- a/usr.sbin/dhcpd/dhcpd.h +++ b/usr.sbin/dhcpd/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.45 2010/04/19 12:22:09 claudio Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.46 2013/02/03 21:04:19 krw Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -679,7 +679,7 @@ void assemble_udp_ip_header(struct interface_info *, unsigned char *, ssize_t decode_hw_header(struct interface_info *, unsigned char *, int, struct hardware *); ssize_t decode_udp_ip_header(struct interface_info *, unsigned char *, - int, struct sockaddr_in *, unsigned char *, int); + int, struct sockaddr_in *, int); u_int32_t checksum(unsigned char *, unsigned, u_int32_t); u_int32_t wrapsum(u_int32_t); diff --git a/usr.sbin/dhcpd/packet.c b/usr.sbin/dhcpd/packet.c index 00e06d7dd97..30d221605a7 100644 --- a/usr.sbin/dhcpd/packet.c +++ b/usr.sbin/dhcpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.4 2013/01/05 12:34:53 krw Exp $ */ +/* $OpenBSD: packet.c,v 1.5 2013/02/03 21:04:19 krw Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -160,10 +160,11 @@ decode_hw_header(struct interface_info *interface, unsigned char *buf, ssize_t decode_udp_ip_header(struct interface_info *interface, unsigned char *buf, - int bufix, struct sockaddr_in *from, unsigned char *data, int buflen) + int bufix, struct sockaddr_in *from, int buflen) { struct ip *ip; struct udphdr *udp; + unsigned char *data; u_int32_t ip_len = (buf[bufix] & 0xf) << 2; u_int32_t sum, usum; static int ip_packets_seen; @@ -172,7 +173,7 @@ decode_udp_ip_header(struct interface_info *interface, unsigned char *buf, static int udp_packets_bad_checksum; static int udp_packets_length_checked; static int udp_packets_length_overflow; - int len = 0; + int len; ip = (struct ip *)(buf + bufix); udp = (struct udphdr *)(buf + bufix + ip_len); @@ -198,29 +199,27 @@ decode_udp_ip_header(struct interface_info *interface, unsigned char *buf, /* * Compute UDP checksums, including the ``pseudo-header'', the - * UDP header and the data. If the UDP checksum field is zero, + * UDP header and the data. If the UDP checksum field is zero, * we're not supposed to do a checksum. */ - if (!data) { - data = buf + bufix + ip_len + sizeof(*udp); - len = ntohs(udp->uh_ulen) - sizeof(*udp); - udp_packets_length_checked++; - if ((len < 0) || (len + data > buf + bufix + buflen)) { - udp_packets_length_overflow++; - if (udp_packets_length_checked > 4 && - (udp_packets_length_checked / - udp_packets_length_overflow) < 2) { - note("%d udp packets in %d too long - dropped", - udp_packets_length_overflow, - udp_packets_length_checked); - udp_packets_length_overflow = - udp_packets_length_checked = 0; - } - return (-1); + data = buf + bufix + ip_len + sizeof(*udp); + len = ntohs(udp->uh_ulen) - sizeof(*udp); + udp_packets_length_checked++; + if ((len < 0) || (len + data > buf + bufix + buflen)) { + udp_packets_length_overflow++; + if (udp_packets_length_checked > 4 && + (udp_packets_length_checked / + udp_packets_length_overflow) < 2) { + note("%d udp packets in %d too long - dropped", + udp_packets_length_overflow, + udp_packets_length_checked); + udp_packets_length_overflow = + udp_packets_length_checked = 0; } - if (len + data != buf + bufix + buflen) - debug("accepting packet with data after udp payload."); + return (-1); } + if (len + data != buf + bufix + buflen) + debug("accepting packet with data after udp payload."); usum = udp->uh_sum; udp->uh_sum = 0; |