aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 23:44:57 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-27 23:44:57 +0000
commit229b3d207216b23a107e4e1ee5584412f6b9318d (patch)
treed21a19b020f0ff35f7d0fa24f9812d68057ff06a /networking/libiproute
parente2d3ded3549edd58fe3b39f2254c65f0808bcac2 (diff)
downloadbusybox-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/libiproute')
-rw-r--r--networking/libiproute/ipaddress.c2
-rw-r--r--networking/libiproute/iplink.c14
-rw-r--r--networking/libiproute/iptunnel.c14
3 files changed, 15 insertions, 15 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 42cf629c6..2a267fef6 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -86,7 +86,7 @@ static void print_queuelen(char *name)
return;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, name);
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) {
perror("SIOCGIFXQLEN");
close(s);
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index f79dab402..1ea11f60b 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -61,7 +61,7 @@ static int do_chflags(char *dev, __u32 flags, __u32 mask)
int fd;
int err;
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
fd = get_ctl_fd();
if (fd < 0)
return -1;
@@ -88,8 +88,8 @@ static int do_changename(char *dev, char *newdev)
int fd;
int err;
- strcpy(ifr.ifr_name, dev);
- strcpy(ifr.ifr_newname, newdev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_newname, newdev, sizeof(ifr.ifr_newname));
fd = get_ctl_fd();
if (fd < 0)
return -1;
@@ -113,7 +113,7 @@ static int set_qlen(char *dev, int qlen)
return -1;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
ifr.ifr_qlen = qlen;
if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) {
perror("SIOCSIFXQLEN");
@@ -135,7 +135,7 @@ static int set_mtu(char *dev, int mtu)
return -1;
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
if (ioctl(s, SIOCSIFMTU, &ifr) < 0) {
perror("SIOCSIFMTU");
@@ -161,7 +161,7 @@ static int get_address(char *dev, int *htype)
}
memset(&ifr, 0, sizeof(ifr));
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
perror("SIOCGIFINDEX");
close(s);
@@ -194,7 +194,7 @@ static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr
int alen;
memset(ifr, 0, sizeof(*ifr));
- strcpy(ifr->ifr_name, dev);
+ strncpy(ifr->ifr_name, dev, sizeof(ifr->ifr_name));
ifr->ifr_hwaddr.sa_family = hatype;
alen = ll_addr_a2n((unsigned char *)(ifr->ifr_hwaddr.sa_data), 14, lla);
if (alen < 0)
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 2b9d3055e..2080324ac 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -42,7 +42,7 @@ static int do_ioctl_get_ifindex(char *dev)
struct ifreq ifr;
int fd;
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(fd, SIOCGIFINDEX, &ifr)) {
bb_perror_msg("ioctl");
@@ -57,7 +57,7 @@ static int do_ioctl_get_iftype(char *dev)
struct ifreq ifr;
int fd;
- strcpy(ifr.ifr_name, dev);
+ strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(fd, SIOCGIFHWADDR, &ifr)) {
bb_perror_msg("ioctl");
@@ -91,7 +91,7 @@ static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p)
int fd;
int err;
- strcpy(ifr.ifr_name, basedev);
+ strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl(fd, SIOCGETTUNNEL, &ifr);
@@ -109,9 +109,9 @@ static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p)
int err;
if (cmd == SIOCCHGTUNNEL && p->name[0]) {
- strcpy(ifr.ifr_name, p->name);
+ strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
} else {
- strcpy(ifr.ifr_name, basedev);
+ strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
}
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
@@ -130,9 +130,9 @@ static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p)
int err;
if (p->name[0]) {
- strcpy(ifr.ifr_name, p->name);
+ strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
} else {
- strcpy(ifr.ifr_name, basedev);
+ strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
}
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);