summaryrefslogtreecommitdiff
path: root/networking/interface.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-12-02 18:18:50 +0000
committerDenis Vlasenko2008-12-02 18:18:50 +0000
commit360d9661b6a33b0358104623058f1c3629a469ea (patch)
tree268954b686b38c96428e3b74fc1ebb2ebdfdfb32 /networking/interface.c
parent928b2c0fee65cae10f683ee0f1ea8d0a29a54924 (diff)
downloadbusybox-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/interface.c')
-rw-r--r--networking/interface.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/networking/interface.c b/networking/interface.c
index 00174d4..ef187be 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -395,7 +395,7 @@ static struct interface *add_interface(char *name)
}
new = xzalloc(sizeof(*new));
- strncpy(new->name, name, IFNAMSIZ);
+ strncpy_IFNAMSIZ(new->name, name);
nextp = ife ? &ife->next : &int_list;
new->prev = ife;
new->next = *nextp;
@@ -614,39 +614,39 @@ static int if_fetch(struct interface *ife)
skfd = xsocket(AF_INET, SOCK_DGRAM, 0);
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) {
close(skfd);
return -1;
}
ife->flags = ifr.ifr_flags;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
memset(ife->hwaddr, 0, 32);
if (ioctl(skfd, SIOCGIFHWADDR, &ifr) >= 0)
memcpy(ife->hwaddr, ifr.ifr_hwaddr.sa_data, 8);
ife->type = ifr.ifr_hwaddr.sa_family;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
ife->metric = 0;
if (ioctl(skfd, SIOCGIFMETRIC, &ifr) >= 0)
ife->metric = ifr.ifr_metric;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
ife->mtu = 0;
if (ioctl(skfd, SIOCGIFMTU, &ifr) >= 0)
ife->mtu = ifr.ifr_mtu;
memset(&ife->map, 0, sizeof(struct ifmap));
#ifdef SIOCGIFMAP
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
if (ioctl(skfd, SIOCGIFMAP, &ifr) == 0)
ife->map = ifr.ifr_map;
#endif
#ifdef HAVE_TXQUEUELEN
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
ife->tx_queue_len = -1; /* unknown value */
if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) >= 0)
ife->tx_queue_len = ifr.ifr_qlen;
@@ -654,23 +654,23 @@ static int if_fetch(struct interface *ife)
ife->tx_queue_len = -1; /* unknown value */
#endif
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
ifr.ifr_addr.sa_family = AF_INET;
memset(&ife->addr, 0, sizeof(struct sockaddr));
if (ioctl(skfd, SIOCGIFADDR, &ifr) == 0) {
ife->has_ip = 1;
ife->addr = ifr.ifr_addr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
if (ioctl(skfd, SIOCGIFDSTADDR, &ifr) >= 0)
ife->dstaddr = ifr.ifr_dstaddr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
memset(&ife->broadaddr, 0, sizeof(struct sockaddr));
if (ioctl(skfd, SIOCGIFBRDADDR, &ifr) >= 0)
ife->broadaddr = ifr.ifr_broadaddr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
memset(&ife->netmask, 0, sizeof(struct sockaddr));
if (ioctl(skfd, SIOCGIFNETMASK, &ifr) >= 0)
ife->netmask = ifr.ifr_netmask;