summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/dhclient/dhclient.c12
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) &&