diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-07-31 12:12:12 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2020-07-31 12:12:12 +0000 |
commit | 297cd08991bbccb1e7e105c59e1879f9113ecca6 (patch) | |
tree | 906a70877e1e00d6b1e9ba87ab7a2d7a5e94dd67 /sbin/dhclient/dhclient.c | |
parent | 614d5d561a0726afdc5b35633ffef4fd61528e91 (diff) |
Ensure DECLINE messages always contain the address from the OFFER.
DECLINE messages emitted when required options were missing did not contain the
address.
Reported via tech@ and fix tested by Dominik Schreilechner.
Diffstat (limited to 'sbin/dhclient/dhclient.c')
-rw-r--r-- | sbin/dhclient/dhclient.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 007358c5008..9cea1cca23d 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.677 2020/05/28 16:02:56 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.678 2020/07/31 12:12:11 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1205,9 +1205,13 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options) lease = calloc(1, sizeof(*lease)); if (lease == NULL) { log_warn("%s: lease", log_procname); - return NULL; + return NULL; /* Can't even DECLINE. */ } + /* Copy the lease addresses. */ + lease->address.s_addr = packet->yiaddr.s_addr; + lease->next_server.s_addr = packet->siaddr.s_addr; + /* Copy the lease options. */ for (i = 0; i < DHO_COUNT; i++) { if (options[i].len == 0) @@ -1273,7 +1277,6 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options) * If this lease is trying to sell us an address we are already * using, decline it. */ - lease->address.s_addr = packet->yiaddr.s_addr; memset(ifname, 0, sizeof(ifname)); if (addressinuse(ifi->name, lease->address, ifname) != 0 && strncmp(ifname, ifi->name, IF_NAMESIZE) != 0) { @@ -1282,9 +1285,6 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options) goto decline; } - /* Save the siaddr (a.k.a. next-server) info. */ - lease->next_server.s_addr = packet->siaddr.s_addr; - /* If the server name was filled out, copy it. */ if ((lease->options[DHO_DHCP_OPTION_OVERLOAD].len == 0 || (lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2) == 0) && |