diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-11-14 17:48:49 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-11-14 17:48:49 +0000 |
commit | 0ee98c2d517d93f0d57147d966cee8711f693ed6 (patch) | |
tree | fe73acea69ab6109b4b26b711f42b77ed0cdd219 /sbin | |
parent | c2e95cdaa9b7e2a3f403b0ad578cc58e20165523 (diff) |
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@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 10 |
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; } } |