svn commit: trunk/busybox: e2fsprogs/old_e2fsprogs/uuid include lib etc...

vda at busybox.net vda at busybox.net
Tue Dec 2 18:18:51 UTC 2008


Author: vda
Date: 2008-12-02 10:18:50 -0800 (Tue, 02 Dec 2008)
New Revision: 24233

Log:
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




Modified:
   trunk/busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/xfuncs.c
   trunk/busybox/networking/arping.c
   trunk/busybox/networking/brctl.c
   trunk/busybox/networking/ether-wake.c
   trunk/busybox/networking/ifconfig.c
   trunk/busybox/networking/ifenslave.c
   trunk/busybox/networking/interface.c
   trunk/busybox/networking/libiproute/ipaddress.c
   trunk/busybox/networking/libiproute/iplink.c
   trunk/busybox/networking/libiproute/iptunnel.c
   trunk/busybox/networking/libiproute/ll_map.c
   trunk/busybox/networking/nameif.c
   trunk/busybox/networking/route.c
   trunk/busybox/networking/traceroute.c
   trunk/busybox/networking/udhcp/socket.c
   trunk/busybox/networking/vconfig.c
   trunk/busybox/networking/zcip.c


Changeset:
Modified: trunk/busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c
===================================================================
--- trunk/busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -165,7 +165,7 @@
 	n = ifc.ifc_len;
 	for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
 		ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
-		strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
+		strncpy_IFNAMSIZ(ifr.ifr_name, ifrp->ifr_name);
 #ifdef SIOCGIFHWADDR
 		if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
 			continue;

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/include/libbb.h	2008-12-02 18:18:50 UTC (rev 24233)
@@ -540,6 +540,7 @@
 char *xstrndup(const char *s, int n) FAST_FUNC;
 void overlapping_strcpy(char *dst, const char *src) FAST_FUNC;
 char *safe_strncpy(char *dst, const char *src, size_t size) FAST_FUNC;
+char *strncpy_IFNAMSIZ(char *dst, const char *src) FAST_FUNC;
 /* Guaranteed to NOT be a macro (smallest code). Saves nearly 2k on uclibc.
  * But potentially slow, don't use in one-billion-times loops */
 int bb_putchar(int ch) FAST_FUNC;

Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/libbb/xfuncs.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -40,6 +40,14 @@
 	return fcntl(fd, F_SETFD, FD_CLOEXEC);
 }
 
+char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
+{
+#ifndef IFNAMSIZ
+	enum { IFNAMSIZ = 16 };
+#endif
+	return strncpy(dst, src, IFNAMSIZ);
+}
+
 /* Convert unsigned long long value into compact 4-char
  * representation. Examples: "1234", "1.2k", " 27M", "123T"
  * String is not terminated (buf[4] is untouched) */

Modified: trunk/busybox/networking/arping.c
===================================================================
--- trunk/busybox/networking/arping.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/arping.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -286,7 +286,7 @@
 		struct ifreq ifr;
 
 		memset(&ifr, 0, sizeof(ifr));
-		strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name) - 1);
+		strncpy_IFNAMSIZ(ifr.ifr_name, device);
 		/* We use ifr.ifr_name in error msg so that problem
 		 * with truncated name will be visible */
 		ioctl_or_perror_and_die(sock_fd, SIOCGIFINDEX, &ifr, err_str, "not found");

Modified: trunk/busybox/networking/brctl.c
===================================================================
--- trunk/busybox/networking/brctl.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/brctl.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -137,7 +137,7 @@
 
 				if (!if_indextoname(bridx[i], brname))
 					bb_perror_msg_and_die("can't get bridge name for index %d", i);
-				strncpy(ifr.ifr_name, brname, IFNAMSIZ);
+				strncpy_IFNAMSIZ(ifr.ifr_name, brname);
 
 				arm_ioctl(args, BRCTL_GET_BRIDGE_INFO,
 							(unsigned long) &bi, 0);
@@ -191,7 +191,7 @@
 		if (!*argv) /* all but 'addif/delif' need at least two arguments */
 			bb_show_usage();
 
-		strncpy(ifr.ifr_name, br, IFNAMSIZ);
+		strncpy_IFNAMSIZ(ifr.ifr_name, br);
 		if (key == ARG_addif || key == ARG_delif) { /* addif or delif */
 			brif = *argv;
 			ifr.ifr_ifindex = if_nametoindex(brif);

Modified: trunk/busybox/networking/ether-wake.c
===================================================================
--- trunk/busybox/networking/ether-wake.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/ether-wake.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -219,7 +219,7 @@
 	{
 		struct ifreq if_hwaddr;
 
-		strncpy(if_hwaddr.ifr_name, ifname, sizeof(if_hwaddr.ifr_name));
+		strncpy_IFNAMSIZ(if_hwaddr.ifr_name, ifname);
 		ioctl_or_perror_and_die(s, SIOCGIFHWADDR, &if_hwaddr, "SIOCGIFHWADDR on %s failed", ifname);
 
 		memcpy(outpack+6, if_hwaddr.ifr_hwaddr.sa_data, 6);
@@ -255,7 +255,7 @@
 #if defined(PF_PACKET)
 	{
 		struct ifreq ifr;
-		strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+		strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
 		xioctl(s, SIOCGIFINDEX, &ifr);
 		memset(&whereto, 0, sizeof(whereto));
 		whereto.sll_family = AF_PACKET;

Modified: trunk/busybox/networking/ifconfig.c
===================================================================
--- trunk/busybox/networking/ifconfig.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/ifconfig.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -313,7 +313,7 @@
 	sockfd = xsocket(AF_INET, SOCK_DGRAM, 0);
 
 	/* get interface name */
-	strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
+	strncpy_IFNAMSIZ(ifr.ifr_name, *argv);
 
 	/* Process the remaining arguments. */
 	while (*++argv != (char *) NULL) {

Modified: trunk/busybox/networking/ifenslave.c
===================================================================
--- trunk/busybox/networking/ifenslave.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/ifenslave.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -140,11 +140,6 @@
 
 /* NOINLINEs are placed where it results in smaller code (gcc 4.3.1) */
 
-static void strncpy_IFNAMSIZ(char *dst, const char *src)
-{
-	strncpy(dst, src, IFNAMSIZ);
-}
-
 static int ioctl_on_skfd(unsigned request, struct ifreq *ifr)
 {
 	return ioctl(skfd, request, ifr);

Modified: trunk/busybox/networking/interface.c
===================================================================
--- trunk/busybox/networking/interface.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/interface.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -395,7 +395,7 @@
 	}
 
 	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 @@
 
 	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 @@
 	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;

Modified: trunk/busybox/networking/libiproute/ipaddress.c
===================================================================
--- trunk/busybox/networking/libiproute/ipaddress.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/libiproute/ipaddress.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -83,7 +83,7 @@
 		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;

Modified: trunk/busybox/networking/libiproute/iplink.c
===================================================================
--- trunk/busybox/networking/libiproute/iplink.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/libiproute/iplink.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -41,7 +41,7 @@
 	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 @@
 	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 @@
 
 	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 @@
 
 	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 @@
 	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 @@
 	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*/;

Modified: trunk/busybox/networking/libiproute/iptunnel.c
===================================================================
--- trunk/busybox/networking/libiproute/iptunnel.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/libiproute/iptunnel.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -34,7 +34,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 				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 @@
 			}
 			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 @@
 	}
 }
 
-
 /* Return value becomes exitcode. It's okay to not return at all */
 static int do_add(int cmd, char **argv)
 {

Modified: trunk/busybox/networking/libiproute/ll_map.c
===================================================================
--- trunk/busybox/networking/libiproute/ll_map.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/libiproute/ll_map.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -176,7 +176,7 @@
 		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);

Modified: trunk/busybox/networking/nameif.c
===================================================================
--- trunk/busybox/networking/nameif.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/nameif.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -177,7 +177,7 @@
 
 		/* Find the current interface name and copy it to ifr.ifr_name */
 		memset(&ifr, 0, sizeof(struct ifreq));
-		strncpy(ifr.ifr_name, token[0], sizeof(ifr.ifr_name));
+		strncpy_IFNAMSIZ(ifr.ifr_name, token[0]);
 
 #if ENABLE_FEATURE_NAMEIF_EXTENDED
 		/* Check for driver etc. */

Modified: trunk/busybox/networking/route.c
===================================================================
--- trunk/busybox/networking/route.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/route.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -423,7 +423,7 @@
 	if (devname) {
 		struct ifreq ifr;
 		memset(&ifr, 0, sizeof(ifr));
-		strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name));
+		strncpy_IFNAMSIZ(ifr.ifr_name, devname);
 		xioctl(skfd, SIOGIFINDEX, &ifr);
 		rt.rtmsg_ifindex = ifr.ifr_ifindex;
 	}

Modified: trunk/busybox/networking/traceroute.c
===================================================================
--- trunk/busybox/networking/traceroute.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/traceroute.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -447,7 +447,7 @@
 		 * SIOCGIFFLAGS stomps over it because the requests
 		 * are returned in a union.)
 		 */
-		strncpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name));
+		strncpy_IFNAMSIZ(ifr.ifr_name, ifrp->ifr_name);
 		if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) {
 			if (errno == ENXIO)
 				continue;

Modified: trunk/busybox/networking/udhcp/socket.c
===================================================================
--- trunk/busybox/networking/udhcp/socket.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/udhcp/socket.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -47,7 +47,7 @@
 	fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW);
 
 	ifr.ifr_addr.sa_family = AF_INET;
-	strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
+	strncpy_IFNAMSIZ(ifr.ifr_name, interface);
 	if (addr) {
 		if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr,
 			"is interface %s up and configured?", interface)

Modified: trunk/busybox/networking/vconfig.c
===================================================================
--- trunk/busybox/networking/vconfig.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/vconfig.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -133,7 +133,7 @@
 	if (ifr.cmd == SET_VLAN_NAME_TYPE_CMD) { /* set_name_type */
 		ifr.u.name_type = *xfind_str(name_types+1, argv[1]);
 	} else {
-		strncpy(ifr.device1, argv[1], IFNAMSIZ);
+		strncpy_IFNAMSIZ(ifr.device1, argv[1]);
 		p = argv[2];
 
 		/* I suppose one could try to combine some of the function calls below,

Modified: trunk/busybox/networking/zcip.c
===================================================================
--- trunk/busybox/networking/zcip.c	2008-12-02 17:15:35 UTC (rev 24232)
+++ trunk/busybox/networking/zcip.c	2008-12-02 18:18:50 UTC (rev 24233)
@@ -268,7 +268,7 @@
 
 	// get the interface's ethernet address
 	//memset(&ifr, 0, sizeof(ifr));
-	strncpy(ifr.ifr_name, argv_intf, sizeof(ifr.ifr_name));
+	strncpy_IFNAMSIZ(ifr.ifr_name, argv_intf);
 	xioctl(sock_fd, SIOCGIFHWADDR, &ifr);
 	memcpy(&eth_addr, &ifr.ifr_hwaddr.sa_data, ETH_ALEN);
 




More information about the busybox-cvs mailing list