9
0
Fork 0

Use safe_strncpy() instead of copy_filename(). The shell has already removed

quotes, so we don't need this functionality from copy_filename()
This commit is contained in:
Sascha Hauer 2007-09-28 10:47:19 +02:00
parent 5931ed5a14
commit 6b7fdcb970
4 changed files with 5 additions and 19 deletions

View File

@ -32,6 +32,7 @@
#include <fs.h>
#include <fcntl.h>
#include <errno.h>
#include <libbb.h>
static int netboot_common (proto_t, cmd_tbl_t *, int , char *[]);
@ -182,7 +183,7 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
return 1;
}
copy_filename (BootFile, argv[2], sizeof(BootFile));
safe_strncpy (BootFile, argv[2], sizeof(BootFile));
if ((size = NetLoop(proto)) < 0)
return 1;

View File

@ -424,9 +424,6 @@ IPaddr_t getenv_IPaddr (char *);
/* 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);

View File

@ -20,6 +20,7 @@
#include <environment.h>
#include <clock.h>
#include <net.h>
#include <libbb.h>
#include "bootp.h"
#include "tftp.h"
#include "nfs.h"
@ -106,7 +107,7 @@ static void BootpCopyNetParams(Bootp_t *bp)
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 @@ BootpRequest (void)
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

View File

@ -1490,19 +1490,6 @@ NetSetIP(uchar * xip, IPaddr_t dest, int dport, int sport, int len)
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);