diff options
author | Denis Vlasenko | 2008-12-02 18:18:50 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-12-02 18:18:50 +0000 |
commit | 360d9661b6a33b0358104623058f1c3629a469ea (patch) | |
tree | 268954b686b38c96428e3b74fc1ebb2ebdfdfb32 /networking/libiproute/iptunnel.c | |
parent | 928b2c0fee65cae10f683ee0f1ea8d0a29a54924 (diff) | |
download | busybox-360d9661b6a33b0358104623058f1c3629a469ea.zip busybox-360d9661b6a33b0358104623058f1c3629a469ea.tar.gz |
libbb: add strncpy_IFNAMSIZ
function old new delta
...
udhcp_read_interface 225 220 -5
brctl_main 1151 1146 -5
add_interface 109 104 -5
ipaddr_list_or_flush 2174 2167 -7
do_add_ioctl 88 80 -8
vconfig_main 249 240 -9
do_del_ioctl 78 68 -10
do_iplink 1186 1173 -13
do_if_fetch 766 753 -13
buffer_fill_and_print 196 179 -17
parse_args 1709 1684 -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/20 up/down: 11/-140) Total: -129 bytes
Diffstat (limited to 'networking/libiproute/iptunnel.c')
-rw-r--r-- | networking/libiproute/iptunnel.c | 21 |
1 files changed, 10 insertions, 11 deletions
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) { |