summaryrefslogtreecommitdiff
path: root/networking/libiproute
diff options
context:
space:
mode:
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.c21
-rw-r--r--networking/libiproute/ll_map.c2
4 files changed, 19 insertions, 20 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 288dcca..fadab6f 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -83,7 +83,7 @@ static void print_queuelen(char *name)
return;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, name);
if (ioctl_or_warn(s, SIOCGIFTXQLEN, &ifr) < 0) {
close(s);
return;
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index 8de17bf..d3d0338 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -41,7 +41,7 @@ static void do_chflags(char *dev, uint32_t flags, uint32_t mask)
struct ifreq ifr;
int fd;
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
fd = get_ctl_fd();
xioctl(fd, SIOCGIFFLAGS, &ifr);
if ((ifr.ifr_flags ^ flags) & mask) {
@@ -58,8 +58,8 @@ static void do_changename(char *dev, char *newdev)
struct ifreq ifr;
int fd;
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
- strncpy(ifr.ifr_newname, newdev, sizeof(ifr.ifr_newname));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
+ strncpy_IFNAMSIZ(ifr.ifr_newname, newdev);
fd = get_ctl_fd();
xioctl(fd, SIOCSIFNAME, &ifr);
close(fd);
@@ -73,7 +73,7 @@ static void set_qlen(char *dev, int qlen)
s = get_ctl_fd();
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
ifr.ifr_qlen = qlen;
xioctl(s, SIOCSIFTXQLEN, &ifr);
close(s);
@@ -87,7 +87,7 @@ static void set_mtu(char *dev, int mtu)
s = get_ctl_fd();
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
ifr.ifr_mtu = mtu;
xioctl(s, SIOCSIFMTU, &ifr);
close(s);
@@ -104,7 +104,7 @@ static int get_address(char *dev, int *htype)
s = xsocket(PF_PACKET, SOCK_DGRAM, 0);
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
xioctl(s, SIOCGIFINDEX, &ifr);
memset(&me, 0, sizeof(me));
@@ -128,7 +128,7 @@ static void parse_address(char *dev, int hatype, int halen, char *lla, struct if
int alen;
memset(ifr, 0, sizeof(*ifr));
- strncpy(ifr->ifr_name, dev, sizeof(ifr->ifr_name));
+ strncpy_IFNAMSIZ(ifr->ifr_name, dev);
ifr->ifr_hwaddr.sa_family = hatype;
alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/;
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 65c27f9..ab4d65b 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -34,7 +34,7 @@ static int do_ioctl_get_ifindex(char *dev)
struct ifreq ifr;
int fd;
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
xioctl(fd, SIOCGIFINDEX, &ifr);
close(fd);
@@ -47,7 +47,7 @@ static int do_ioctl_get_iftype(char *dev)
int fd;
int err;
- strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, dev);
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr);
close(fd);
@@ -73,7 +73,7 @@ static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p)
int fd;
int err;
- strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, basedev);
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
err = ioctl_or_warn(fd, SIOCGETTUNNEL, &ifr);
@@ -88,9 +88,9 @@ static int do_add_ioctl(int cmd, const char *basedev, struct ip_tunnel_parm *p)
int fd;
if (cmd == SIOCCHGTUNNEL && p->name[0]) {
- strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, p->name);
} else {
- strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, basedev);
}
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
@@ -114,9 +114,9 @@ static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p)
int fd;
if (p->name[0]) {
- strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, p->name);
} else {
- strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, basedev);
}
ifr.ifr_ifru.ifru_data = (void*)p;
fd = xsocket(AF_INET, SOCK_DGRAM, 0);
@@ -148,7 +148,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
int key;
memset(p, 0, sizeof(*p));
- memset(&medium, 0, sizeof(medium));
+ medium[0] = '\0';
p->iph.version = 4;
p->iph.ihl = 5;
@@ -250,7 +250,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
p->iph.saddr = get_addr32(*argv);
} else if (key == ARG_dev) {
NEXT_ARG();
- strncpy(medium, *argv, IFNAMSIZ-1);
+ strncpy_IFNAMSIZ(medium, *argv);
} else if (key == ARG_ttl) {
unsigned uval;
NEXT_ARG();
@@ -279,7 +279,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
}
if (p->name[0])
duparg2("name", *argv);
- strncpy(p->name, *argv, IFNAMSIZ);
+ strncpy_IFNAMSIZ(p->name, *argv);
if (cmd == SIOCCHGTUNNEL && count == 0) {
struct ip_tunnel_parm old_p;
memset(&old_p, 0, sizeof(old_p));
@@ -324,7 +324,6 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p)
}
}
-
/* Return value becomes exitcode. It's okay to not return at all */
static int do_add(int cmd, char **argv)
{
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c
index eeae4e2..3412dc7 100644
--- a/networking/libiproute/ll_map.c
+++ b/networking/libiproute/ll_map.c
@@ -176,7 +176,7 @@ int xll_name_to_index(const char *const name)
struct ifreq ifr;
int tmp;
- strncpy(ifr.ifr_name, name, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, name);
ifr.ifr_ifindex = -1;
tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr);
close(sock_fd);