summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dhcrelay
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2016-02-02 23:15:15 +0000
committersthen <sthen@openbsd.org>2016-02-02 23:15:15 +0000
commit23d823c356516de34ef3eb7b329e85baeee48df2 (patch)
treee2eaf2c115bb86b01bf987a481c58de4731cf3d0 /usr.sbin/dhcrelay
parentgive sxidog it's own mapping as well so it wont't require sxitimer (diff)
downloadwireguard-openbsd-23d823c356516de34ef3eb7b329e85baeee48df2.tar.xz
wireguard-openbsd-23d823c356516de34ef3eb7b329e85baeee48df2.zip
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.c4
-rw-r--r--usr.sbin/dhcrelay/dhcpd.h4
-rw-r--r--usr.sbin/dhcrelay/packet.c45
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;