diff --git a/commands/net.c b/commands/net.c index 2f1bf13..99fc870 100644 --- a/commands/net.c +++ b/commands/net.c @@ -32,6 +32,7 @@ #include #include #include +#include static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]); @@ -182,7 +183,7 @@ return 1; } - copy_filename (BootFile, argv[2], sizeof(BootFile)); + safe_strncpy (BootFile, argv[2], sizeof(BootFile)); if ((size = NetLoop(proto)) < 0) return 1; diff --git a/include/net.h b/include/net.h index 8507360..3bc712e 100644 --- a/include/net.h +++ b/include/net.h @@ -424,9 +424,6 @@ /* read a VLAN id from an environment variable */ ushort getenv_VLAN(char *); -/* copy a filename (allow for "..." notation, limit length) */ -void copy_filename (char *dst, char *src, int size); - int string_to_enet_addr(const char *str, char *enetaddr); void enet_addr_to_string(const unsigned char *enetaddr, char *str); diff --git a/net/bootp.c b/net/bootp.c index 419a40e..7340ed9 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "bootp.h" #include "tftp.h" #include "nfs.h" @@ -106,7 +107,7 @@ NetCopyIP(&NetServerIP, &bp->bp_siaddr); memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6); if (strlen(bp->bp_file) > 0) - copy_filename (BootFile, bp->bp_file, sizeof(BootFile)); + safe_strncpy (BootFile, bp->bp_file, sizeof(BootFile)); debug ("Bootfile: %s\n", BootFile); @@ -564,7 +565,7 @@ NetWriteIP(&bp->bp_siaddr, 0); NetWriteIP(&bp->bp_giaddr, 0); memcpy (bp->bp_chaddr, NetOurEther, 6); - copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file)); + safe_strncpy (bp->bp_file, BootFile, sizeof(bp->bp_file)); /* Request additional information from the BOOTP/DHCP server */ #ifdef CONFIG_NET_DHCP diff --git a/net/net.c b/net/net.c index 331269d..2627a20 100644 --- a/net/net.c +++ b/net/net.c @@ -1490,19 +1490,6 @@ ip->ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); } -void copy_filename (char *dst, char *src, int size) -{ - if (*src && (*src == '"')) { - ++src; - --size; - } - - while ((--size > 0) && *src && (*src != '"')) { - *dst++ = *src++; - } - *dst = '\0'; -} - char *ip_to_string (IPaddr_t x, char *s) { x = ntohl (x);