summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-02-03 20:06:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-02-03 20:06:28 +0000
commitcb21bce4874f417ceeea5dd7cb32572bbb51db1b (patch)
treec7e18e64079931af54eea3b7b01b4f6ff3cd3962 /sys/net
parent1003e0f24def667c74868ba2934acdee65c480a5 (diff)
handle interface unit numbers up to 2G-1; skip if total name is too long
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8fd2138f43f..9b6f22c4465 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -580,15 +580,23 @@ ifconf(cmd, data)
register char *cp, *ep;
struct ifreq ifr, *ifrp;
int space = ifc->ifc_len, error = 0;
+ int i, ndig;
ifrp = ifc->ifc_req;
- ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2;
+ ep = ifr.ifr_name + sizeof (ifr.ifr_name);
for (ifp = ifnet.tqh_first;
space > sizeof (ifr) && ifp != 0; ifp = ifp->if_list.tqe_next) {
strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2);
for (cp = ifr.ifr_name; cp < ep && *cp; cp++)
continue;
- *cp++ = '0' + ifp->if_unit; *cp = '\0';
+ for (i = ifp->if_unit, ndig = 0; i; i /= 10)
+ ndig++;
+ cp += ndig;
+ if (cp >= ep)
+ continue;
+ *cp = '\0';
+ for (i = ifp->if_unit; i; i /= 10)
+ *--cp = '0' + (i % 10);
if ((ifa = ifp->if_addrlist.tqh_first) == 0) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
error = copyout((caddr_t)&ifr, (caddr_t)ifrp,