diff mbox series

[kvmtool,3/3] net/dhcp: avoid misleading strncpy

Message ID 20190204163458.188070-4-andre.przywara@arm.com (mailing list archive)
State New, archived
Headers show
Series Fix more GCC 8 strncpy warnings | expand

Commit Message

Andre Przywara Feb. 4, 2019, 4:34 p.m. UTC
The code for copying an empty IP address into the DHCP opt buffer used
strncpy, however used the source length as the size argument. GCC 8.x
complains about it.

Since the source string is actually fixed, just revert to the old
strcpy, which gives us actually the same level of security in this case,
but makes the compiler happy.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 net/uip/dhcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/uip/dhcp.c b/net/uip/dhcp.c
index 8f013002..9de5588b 100644
--- a/net/uip/dhcp.c
+++ b/net/uip/dhcp.c
@@ -131,7 +131,7 @@  static int uip_dhcp_fill_option(struct uip_info *info, struct uip_dhcp *dhcp, in
 	opt[i++]	= UIP_DHCP_TAG_ROOT;
 	opt[i++]	= strlen(EMPTY_ADDR);
 	addr		= (u32 *)&opt[i];
-	strncpy((void *) addr, EMPTY_ADDR, strlen(EMPTY_ADDR));
+	strcpy((void *) addr, EMPTY_ADDR);
 	i		+= strlen(EMPTY_ADDR);
 
 	i 		= uip_dhcp_fill_option_name_and_server(info, opt, i);