summaryrefslogtreecommitdiff
path: root/networking/interface.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-11-27 23:44:57 +0000
committerDenis Vlasenko2006-11-27 23:44:57 +0000
commit229b3d207216b23a107e4e1ee5584412f6b9318d (patch)
treed21a19b020f0ff35f7d0fa24f9812d68057ff06a /networking/interface.c
parente2d3ded3549edd58fe3b39f2254c65f0808bcac2 (diff)
downloadbusybox-229b3d207216b23a107e4e1ee5584412f6b9318d.zip
busybox-229b3d207216b23a107e4e1ee5584412f6b9318d.tar.gz
do not overflow ifr_name. maybe it was safe in some places,
but not everywhere. err to the safe side.
Diffstat (limited to 'networking/interface.c')
-rw-r--r--networking/interface.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/networking/interface.c b/networking/interface.c
index 5f54fd9..cabfc06 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -617,12 +617,12 @@ static int if_fetch(struct interface *ife)
int fd;
char *ifname = ife->name;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
return -1;
ife->flags = ifr.ifr_flags;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
memset(ife->hwaddr, 0, 32);
else
@@ -630,20 +630,20 @@ static int if_fetch(struct interface *ife)
ife->type = ifr.ifr_hwaddr.sa_family;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMETRIC, &ifr) < 0)
ife->metric = 0;
else
ife->metric = ifr.ifr_metric;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0)
ife->mtu = 0;
else
ife->mtu = ifr.ifr_mtu;
#ifdef SIOCGIFMAP
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0)
ife->map = ifr.ifr_map;
else
@@ -651,7 +651,7 @@ static int if_fetch(struct interface *ife)
memset(&ife->map, 0, sizeof(struct ifmap));
#ifdef HAVE_TXQUEUELEN
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) < 0)
ife->tx_queue_len = -1; /* unknown value */
else
@@ -663,24 +663,24 @@ static int if_fetch(struct interface *ife)
/* IPv4 address? */
fd = get_socket_for_af(AF_INET);
if (fd >= 0) {
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_addr.sa_family = AF_INET;
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
ife->has_ip = 1;
ife->addr = ifr.ifr_addr;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0)
memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
else
ife->dstaddr = ifr.ifr_dstaddr;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0)
memset(&ife->broadaddr, 0, sizeof(struct sockaddr));
else
ife->broadaddr = ifr.ifr_broadaddr;
- strcpy(ifr.ifr_name, ifname);
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0)
memset(&ife->netmask, 0, sizeof(struct sockaddr));
else