From e8a353af056895e8fececc1a091f20441fd76079 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Sun, 20 Sep 2020 23:08:47 +0900 Subject: [PATCH] netutils: dhcpc: Fix dhcpc.c Summary: - dhcpc now uses gethostname() but the hostname might be empty - This commit fixes this issue Impact: - All use cases which use dhcpc Testing: - Tested with spresense:wifi Signed-off-by: Masayuki Ishikawa --- netutils/dhcpc/dhcpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index 6198b4449..c9c454f9c 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -244,7 +244,7 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc, /* Get the current host name */ - if (gethostname(hostname, sizeof(hostname))) + if (gethostname(hostname, sizeof(hostname)) || (0 == strlen(hostname))) { strncpy(hostname, CONFIG_NETUTILS_DHCPC_HOST_NAME, HOST_NAME_MAX); }