From: florian Date: Tue, 26 Apr 2022 14:50:04 +0000 (+0000) Subject: Do not send a hostname option when we don't have a hostname. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8491c0ab37953692561c87ba499f7dce02412cbf;p=openbsd Do not send a hostname option when we don't have a hostname. The minimum length of a hostname is 1 according to RFC 2132. Found the hard way by Ibrahim Khalifa (ibo AT trukonsult.se) with DHCP Relay on a Cisco ASA in the installer where we don't have a hostname yet. Ibrahim also provided a diff which I simplified a bit. OK tb --- diff --git a/sbin/dhcpleased/frontend.c b/sbin/dhcpleased/frontend.c index 58c6153793f..2959a6c0d0f 100644 --- a/sbin/dhcpleased/frontend.c +++ b/sbin/dhcpleased/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.28 2022/01/04 06:20:37 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.29 2022/04/26 14:50:04 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -971,7 +971,8 @@ build_packet(uint8_t message_type, char *if_name, uint32_t xid, #endif /* SMALL */ { if (gethostname(dhcp_hostname + 2, - sizeof(dhcp_hostname) - 2) == 0) { + sizeof(dhcp_hostname) - 2) == 0 && + dhcp_hostname[2] != '\0') { if ((c = strchr(dhcp_hostname + 2, '.')) != NULL) *c = '\0'; dhcp_hostname[1] = strlen(dhcp_hostname + 2);