From 0ee98c2d517d93f0d57147d966cee8711f693ed6 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Tue, 14 Nov 2017 17:48:49 +0000 Subject: 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@ --- sbin/dhclient/dhclient.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sbin') 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 @@ -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; } } -- cgit v1.2.3