summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2017-11-14 17:48:48 +0000
committermpi <mpi@openbsd.org>2017-11-14 17:48:48 +0000
commitaf333735a5126af3057e785b7b6feecc1edb87af (patch)
treed242f5268ece3491b0a91e3b5e1260b3b97e299a
parentPush the NET_LOCK into ifioctl() and use the NET_RLOCK in ifioctl_get(). (diff)
downloadwireguard-openbsd-af333735a5126af3057e785b7b6feecc1edb87af.tar.xz
wireguard-openbsd-af333735a5126af3057e785b7b6feecc1edb87af.zip
Treat invalid server name as empty instead of declining the lease offered
by such misconfigured DHCP servers. Original diff from and ok krw@, ok sthen@
-rw-r--r--sbin/dhclient/dhclient.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 9b6aa648bf9..008bcc3ea09 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.522 2017/11/12 11:18:50 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.523 2017/11/14 17:48:48 mpi Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1242,17 +1242,17 @@ packet_to_lease(struct interface_info *ifi, struct option_data *options)
if ((lease->options[DHO_DHCP_OPTION_OVERLOAD].len == 0 ||
(lease->options[DHO_DHCP_OPTION_OVERLOAD].data[0] & 2) == 0) &&
packet->sname[0]) {
- lease->server_name = malloc(DHCP_SNAME_LEN + 1);
+ lease->server_name = calloc(1, DHCP_SNAME_LEN + 1);
if (lease->server_name == NULL) {
log_warn("%s: SNAME", log_procname);
goto decline;
}
memcpy(lease->server_name, packet->sname, DHCP_SNAME_LEN);
- lease->server_name[DHCP_SNAME_LEN] = '\0';
if (res_hnok(lease->server_name) == 0) {
- log_warnx("%s: invalid host name in SNAME",
+ log_warnx("%s: invalid host name in SNAME ignored",
log_procname);
- goto decline;
+ free(lease->server_name);
+ lease->server_name = NULL;
}
}