diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2016-02-02 23:15:16 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2016-02-02 23:15:16 +0000 |
commit | 970295c7e2cc266374a576a015f4185dbbbaf8cd (patch) | |
tree | 2d53a0441a58e5589eab0cce19c73cdd715d4eba /usr.sbin/dhcrelay | |
parent | c0687fbf020f2c260fb25351f2a5bf3e3632d7f7 (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.
From dhcpd: bpf.c r1.9, dhcpd.h r1.46, packet.c r1.5
ok jca
Diffstat (limited to 'usr.sbin/dhcrelay')
-rw-r--r-- | usr.sbin/dhcrelay/bpf.c | 4 | ||||
-rw-r--r-- | usr.sbin/dhcrelay/dhcpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/dhcrelay/packet.c | 45 |
3 files changed, 26 insertions, 27 deletions
diff --git a/usr.sbin/dhcrelay/bpf.c b/usr.sbin/dhcrelay/bpf.c index fad2e0ad881..8029857f0e6 100644 --- a/usr.sbin/dhcrelay/bpf.c +++ b/usr.sbin/dhcrelay/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.8 2014/10/25 03:23:49 lteo Exp $ */ +/* $OpenBSD: bpf.c,v 1.9 2016/02/02 23:15:15 sthen Exp $ */ /* BPF socket interface code, originally contributed by Archie Cobbs. */ @@ -377,7 +377,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/dhcrelay/dhcpd.h b/usr.sbin/dhcrelay/dhcpd.h index c1d6917460b..c7927aa38eb 100644 --- a/usr.sbin/dhcrelay/dhcpd.h +++ b/usr.sbin/dhcrelay/dhcpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.h,v 1.12 2009/09/03 11:56:49 reyk Exp $ */ +/* $OpenBSD: dhcpd.h,v 1.13 2016/02/02 23:15:15 sthen Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@openbsd.org> @@ -166,7 +166,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); /* dhcrelay.c */ extern u_int16_t server_port; diff --git a/usr.sbin/dhcrelay/packet.c b/usr.sbin/dhcrelay/packet.c index 6352f0cf5a9..1a5af5b5efd 100644 --- a/usr.sbin/dhcrelay/packet.c +++ b/usr.sbin/dhcrelay/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.6 2016/01/13 13:41:42 sthen Exp $ */ +/* $OpenBSD: packet.c,v 1.7 2016/02/02 23:15:15 sthen Exp $ */ /* Packet assembly code, originally contributed by Archie Cobbs. */ @@ -178,10 +178,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; @@ -190,7 +191,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); @@ -216,30 +217,28 @@ 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_overflow != 0 && - (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_overflow != 0 && + (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; |