summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/bpf.c
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-02-14 20:39:46 +0000
committerkrw <krw@openbsd.org>2013-02-14 20:39:46 +0000
commite7cf2d101e016470b7936394d2cac41f3198a815 (patch)
tree517490875b4100145d33f2ae6e7f950854c3414a /sbin/dhclient/bpf.c
parentMerge of an original work by markus@ and gerhard@ to increase (diff)
downloadwireguard-openbsd-e7cf2d101e016470b7936394d2cac41f3198a815.tar.xz
wireguard-openbsd-e7cf2d101e016470b7936394d2cac41f3198a815.zip
Don't rely on the packet buffer (client->packet) being preserved between
attempts to send DISCOVER or REQUEST packets. Some DHCP servers might NAK the DISCOVER, or other nefarious packets arrive, between attempts and overwrite the packet being sent. Create and use another buffer for packets being sent. Problem encountered by fgsch@, who noticed that once the DISCOVER was NAK'ed our dhclient sent a bunch of NAK's back to the server. Like it thought they were DISCOVER messages. ok beck@
Diffstat (limited to 'sbin/dhclient/bpf.c')
-rw-r--r--sbin/dhclient/bpf.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 50f5a7814b5..900039da52e 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.25 2013/02/03 21:04:19 krw Exp $ */
+/* $OpenBSD: bpf.c,v 1.26 2013/02/14 20:39:46 krw Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -274,13 +274,13 @@ send_packet(struct in_addr from, struct sockaddr_in *to,
assemble_udp_ip_header(buf, &bufp, from.s_addr,
to->sin_addr.s_addr, to->sin_port,
- (unsigned char *)&client->packet,
- client->packet_length);
+ (unsigned char *)&client->bootrequest_packet,
+ client->bootrequest_packet_length);
iov[0].iov_base = (char *)buf;
iov[0].iov_len = bufp;
- iov[1].iov_base = (char *)&client->packet;
- iov[1].iov_len = client->packet_length;
+ iov[1].iov_base = (char *)&client->bootrequest_packet;
+ iov[1].iov_len = client->bootrequest_packet_length;
if (to->sin_addr.s_addr == INADDR_BROADCAST) {
result = writev(ifi->wfdesc, iov, IOVCNT);