diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-02 18:18:50 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-12-02 18:18:50 +0000 |
commit | 360d9661b6a33b0358104623058f1c3629a469ea (patch) | |
tree | 268954b686b38c96428e3b74fc1ebb2ebdfdfb32 /networking/libiproute | |
parent | 928b2c0fee65cae10f683ee0f1ea8d0a29a54924 (diff) | |
download | busybox-w32-360d9661b6a33b0358104623058f1c3629a469ea.tar.gz busybox-w32-360d9661b6a33b0358104623058f1c3629a469ea.tar.bz2 busybox-w32-360d9661b6a33b0358104623058f1c3629a469ea.zip |
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')
-rw-r--r-- | networking/libiproute/ipaddress.c | 2 | ||||
-rw-r--r-- | networking/libiproute/iplink.c | 14 | ||||
-rw-r--r-- | networking/libiproute/iptunnel.c | 21 | ||||
-rw-r--r-- | networking/libiproute/ll_map.c | 2 |
4 files changed, 19 insertions, 20 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 288dccae7..fadab6f39 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -83,7 +83,7 @@ static void print_queuelen(char *name) | |||
83 | return; | 83 | return; |
84 | 84 | ||
85 | memset(&ifr, 0, sizeof(ifr)); | 85 | memset(&ifr, 0, sizeof(ifr)); |
86 | strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); | 86 | strncpy_IFNAMSIZ(ifr.ifr_name, name); |
87 | if (ioctl_or_warn(s, SIOCGIFTXQLEN, &ifr) < 0) { | 87 | if (ioctl_or_warn(s, SIOCGIFTXQLEN, &ifr) < 0) { |
88 | close(s); | 88 | close(s); |
89 | return; | 89 | return; |
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index 8de17bfc6..d3d0338b0 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) | |||
41 | struct ifreq ifr; | 41 | struct ifreq ifr; |
42 | int fd; | 42 | int fd; |
43 | 43 | ||
44 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 44 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
45 | fd = get_ctl_fd(); | 45 | fd = get_ctl_fd(); |
46 | xioctl(fd, SIOCGIFFLAGS, &ifr); | 46 | xioctl(fd, SIOCGIFFLAGS, &ifr); |
47 | if ((ifr.ifr_flags ^ flags) & mask) { | 47 | if ((ifr.ifr_flags ^ flags) & mask) { |
@@ -58,8 +58,8 @@ static void do_changename(char *dev, char *newdev) | |||
58 | struct ifreq ifr; | 58 | struct ifreq ifr; |
59 | int fd; | 59 | int fd; |
60 | 60 | ||
61 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 61 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
62 | strncpy(ifr.ifr_newname, newdev, sizeof(ifr.ifr_newname)); | 62 | strncpy_IFNAMSIZ(ifr.ifr_newname, newdev); |
63 | fd = get_ctl_fd(); | 63 | fd = get_ctl_fd(); |
64 | xioctl(fd, SIOCSIFNAME, &ifr); | 64 | xioctl(fd, SIOCSIFNAME, &ifr); |
65 | close(fd); | 65 | close(fd); |
@@ -73,7 +73,7 @@ static void set_qlen(char *dev, int qlen) | |||
73 | 73 | ||
74 | s = get_ctl_fd(); | 74 | s = get_ctl_fd(); |
75 | memset(&ifr, 0, sizeof(ifr)); | 75 | memset(&ifr, 0, sizeof(ifr)); |
76 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 76 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
77 | ifr.ifr_qlen = qlen; | 77 | ifr.ifr_qlen = qlen; |
78 | xioctl(s, SIOCSIFTXQLEN, &ifr); | 78 | xioctl(s, SIOCSIFTXQLEN, &ifr); |
79 | close(s); | 79 | close(s); |
@@ -87,7 +87,7 @@ static void set_mtu(char *dev, int mtu) | |||
87 | 87 | ||
88 | s = get_ctl_fd(); | 88 | s = get_ctl_fd(); |
89 | memset(&ifr, 0, sizeof(ifr)); | 89 | memset(&ifr, 0, sizeof(ifr)); |
90 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 90 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
91 | ifr.ifr_mtu = mtu; | 91 | ifr.ifr_mtu = mtu; |
92 | xioctl(s, SIOCSIFMTU, &ifr); | 92 | xioctl(s, SIOCSIFMTU, &ifr); |
93 | close(s); | 93 | close(s); |
@@ -104,7 +104,7 @@ static int get_address(char *dev, int *htype) | |||
104 | s = xsocket(PF_PACKET, SOCK_DGRAM, 0); | 104 | s = xsocket(PF_PACKET, SOCK_DGRAM, 0); |
105 | 105 | ||
106 | memset(&ifr, 0, sizeof(ifr)); | 106 | memset(&ifr, 0, sizeof(ifr)); |
107 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 107 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
108 | xioctl(s, SIOCGIFINDEX, &ifr); | 108 | xioctl(s, SIOCGIFINDEX, &ifr); |
109 | 109 | ||
110 | memset(&me, 0, sizeof(me)); | 110 | memset(&me, 0, sizeof(me)); |
@@ -128,7 +128,7 @@ static void parse_address(char *dev, int hatype, int halen, char *lla, struct if | |||
128 | int alen; | 128 | int alen; |
129 | 129 | ||
130 | memset(ifr, 0, sizeof(*ifr)); | 130 | memset(ifr, 0, sizeof(*ifr)); |
131 | strncpy(ifr->ifr_name, dev, sizeof(ifr->ifr_name)); | 131 | strncpy_IFNAMSIZ(ifr->ifr_name, dev); |
132 | ifr->ifr_hwaddr.sa_family = hatype; | 132 | ifr->ifr_hwaddr.sa_family = hatype; |
133 | 133 | ||
134 | alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/; | 134 | alen = hatype == 1/*ARPHRD_ETHER*/ ? 14/*ETH_HLEN*/ : 19/*INFINIBAND_HLEN*/; |
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index 65c27f936..ab4d65bd4 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c | |||
@@ -34,7 +34,7 @@ static int do_ioctl_get_ifindex(char *dev) | |||
34 | struct ifreq ifr; | 34 | struct ifreq ifr; |
35 | int fd; | 35 | int fd; |
36 | 36 | ||
37 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 37 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
38 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 38 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
39 | xioctl(fd, SIOCGIFINDEX, &ifr); | 39 | xioctl(fd, SIOCGIFINDEX, &ifr); |
40 | close(fd); | 40 | close(fd); |
@@ -47,7 +47,7 @@ static int do_ioctl_get_iftype(char *dev) | |||
47 | int fd; | 47 | int fd; |
48 | int err; | 48 | int err; |
49 | 49 | ||
50 | strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name)); | 50 | strncpy_IFNAMSIZ(ifr.ifr_name, dev); |
51 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 51 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
52 | err = ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr); | 52 | err = ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr); |
53 | close(fd); | 53 | close(fd); |
@@ -73,7 +73,7 @@ static int do_get_ioctl(const char *basedev, struct ip_tunnel_parm *p) | |||
73 | int fd; | 73 | int fd; |
74 | int err; | 74 | int err; |
75 | 75 | ||
76 | strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name)); | 76 | strncpy_IFNAMSIZ(ifr.ifr_name, basedev); |
77 | ifr.ifr_ifru.ifru_data = (void*)p; | 77 | ifr.ifr_ifru.ifru_data = (void*)p; |
78 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 78 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
79 | err = ioctl_or_warn(fd, SIOCGETTUNNEL, &ifr); | 79 | 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) | |||
88 | int fd; | 88 | int fd; |
89 | 89 | ||
90 | if (cmd == SIOCCHGTUNNEL && p->name[0]) { | 90 | if (cmd == SIOCCHGTUNNEL && p->name[0]) { |
91 | strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name)); | 91 | strncpy_IFNAMSIZ(ifr.ifr_name, p->name); |
92 | } else { | 92 | } else { |
93 | strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name)); | 93 | strncpy_IFNAMSIZ(ifr.ifr_name, basedev); |
94 | } | 94 | } |
95 | ifr.ifr_ifru.ifru_data = (void*)p; | 95 | ifr.ifr_ifru.ifru_data = (void*)p; |
96 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 96 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
@@ -114,9 +114,9 @@ static int do_del_ioctl(const char *basedev, struct ip_tunnel_parm *p) | |||
114 | int fd; | 114 | int fd; |
115 | 115 | ||
116 | if (p->name[0]) { | 116 | if (p->name[0]) { |
117 | strncpy(ifr.ifr_name, p->name, sizeof(ifr.ifr_name)); | 117 | strncpy_IFNAMSIZ(ifr.ifr_name, p->name); |
118 | } else { | 118 | } else { |
119 | strncpy(ifr.ifr_name, basedev, sizeof(ifr.ifr_name)); | 119 | strncpy_IFNAMSIZ(ifr.ifr_name, basedev); |
120 | } | 120 | } |
121 | ifr.ifr_ifru.ifru_data = (void*)p; | 121 | ifr.ifr_ifru.ifru_data = (void*)p; |
122 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); | 122 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
@@ -148,7 +148,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p) | |||
148 | int key; | 148 | int key; |
149 | 149 | ||
150 | memset(p, 0, sizeof(*p)); | 150 | memset(p, 0, sizeof(*p)); |
151 | memset(&medium, 0, sizeof(medium)); | 151 | medium[0] = '\0'; |
152 | 152 | ||
153 | p->iph.version = 4; | 153 | p->iph.version = 4; |
154 | p->iph.ihl = 5; | 154 | p->iph.ihl = 5; |
@@ -250,7 +250,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p) | |||
250 | p->iph.saddr = get_addr32(*argv); | 250 | p->iph.saddr = get_addr32(*argv); |
251 | } else if (key == ARG_dev) { | 251 | } else if (key == ARG_dev) { |
252 | NEXT_ARG(); | 252 | NEXT_ARG(); |
253 | strncpy(medium, *argv, IFNAMSIZ-1); | 253 | strncpy_IFNAMSIZ(medium, *argv); |
254 | } else if (key == ARG_ttl) { | 254 | } else if (key == ARG_ttl) { |
255 | unsigned uval; | 255 | unsigned uval; |
256 | NEXT_ARG(); | 256 | NEXT_ARG(); |
@@ -279,7 +279,7 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p) | |||
279 | } | 279 | } |
280 | if (p->name[0]) | 280 | if (p->name[0]) |
281 | duparg2("name", *argv); | 281 | duparg2("name", *argv); |
282 | strncpy(p->name, *argv, IFNAMSIZ); | 282 | strncpy_IFNAMSIZ(p->name, *argv); |
283 | if (cmd == SIOCCHGTUNNEL && count == 0) { | 283 | if (cmd == SIOCCHGTUNNEL && count == 0) { |
284 | struct ip_tunnel_parm old_p; | 284 | struct ip_tunnel_parm old_p; |
285 | memset(&old_p, 0, sizeof(old_p)); | 285 | memset(&old_p, 0, sizeof(old_p)); |
@@ -324,7 +324,6 @@ static void parse_args(char **argv, int cmd, struct ip_tunnel_parm *p) | |||
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | |||
328 | /* Return value becomes exitcode. It's okay to not return at all */ | 327 | /* Return value becomes exitcode. It's okay to not return at all */ |
329 | static int do_add(int cmd, char **argv) | 328 | static int do_add(int cmd, char **argv) |
330 | { | 329 | { |
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c index eeae4e252..3412dc763 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) | |||
176 | struct ifreq ifr; | 176 | struct ifreq ifr; |
177 | int tmp; | 177 | int tmp; |
178 | 178 | ||
179 | strncpy(ifr.ifr_name, name, IFNAMSIZ); | 179 | strncpy_IFNAMSIZ(ifr.ifr_name, name); |
180 | ifr.ifr_ifindex = -1; | 180 | ifr.ifr_ifindex = -1; |
181 | tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr); | 181 | tmp = ioctl(sock_fd, SIOCGIFINDEX, &ifr); |
182 | close(sock_fd); | 182 | close(sock_fd); |