You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/01/10 13:52:36 UTC
[nuttx-apps] branch master updated: netutils/dhcpc:fix dhcp hostname len error in dhcpc_sendmsg
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 2b2c4805a netutils/dhcpc:fix dhcp hostname len error in dhcpc_sendmsg
2b2c4805a is described below
commit 2b2c4805a4bca19b4798c03c7637a4c7d8a2c757
Author: 田昕 <ti...@xiaomi.com>
AuthorDate: Tue Jan 10 20:10:52 2023 +0800
netutils/dhcpc:fix dhcp hostname len error in dhcpc_sendmsg
Signed-off-by: 田昕 <ti...@xiaomi.com>
---
netutils/dhcpc/dhcpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c
index 92f484364..0d509456a 100644
--- a/netutils/dhcpc/dhcpc.c
+++ b/netutils/dhcpc/dhcpc.c
@@ -231,7 +231,7 @@ static FAR uint8_t *dhcpc_addend(FAR uint8_t *optptr)
static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
FAR struct dhcpc_state *presult, int msgtype)
{
- char hostname[HOST_NAME_MAX];
+ char hostname[HOST_NAME_MAX + 1];
struct sockaddr_in addr;
FAR uint8_t *pend;
in_addr_t serverid = INADDR_BROADCAST;
@@ -257,7 +257,7 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
if (gethostname(hostname, sizeof(hostname)) || (0 == strlen(hostname)))
{
- strncpy(hostname, CONFIG_NETUTILS_DHCPC_HOST_NAME, HOST_NAME_MAX);
+ strlcpy(hostname, CONFIG_NETUTILS_DHCPC_HOST_NAME, sizeof(hostname));
}
/* Handle the message specific settings */