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 <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2020-09-20 23:08:47 +09:00 committed by Xiang Xiao
parent d635fcb2d8
commit e8a353af05

View File

@ -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);
}