summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1999-11-03 21:32:28 +0000
committerarchie <archie@FreeBSD.org>1999-11-03 21:32:28 +0000
commitfcbe1d0da9ff9c517d80e36af909b350125ddfac (patch)
tree28fe0be9a50d4d7b56eaf8f91872a1bce3d4fba2 /sys/net/bpf.c
parent9abf3190953f2696f3a06adb8d27f32221af2823 (diff)
downloadFreeBSD-src-fcbe1d0da9ff9c517d80e36af909b350125ddfac.zip
FreeBSD-src-fcbe1d0da9ff9c517d80e36af909b350125ddfac.tar.gz
Fix bug in BIOCGETIF ioctl() where it would return a bogus interface
name if the interface unit number was greater than 9.
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 5bd8ed5..82c6904 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -114,7 +114,6 @@ static int bpf_allocbufs __P((struct bpf_d *));
static void bpf_attachd __P((struct bpf_d *d, struct bpf_if *bp));
static void bpf_detachd __P((struct bpf_d *d));
static void bpf_freed __P((struct bpf_d *));
-static void bpf_ifname __P((struct ifnet *, struct ifreq *));
static void bpf_mcopy __P((const void *, void *, size_t));
static int bpf_movein __P((struct uio *, int,
struct mbuf **, struct sockaddr *, int *));
@@ -755,13 +754,18 @@ bpfioctl(dev, cmd, addr, flags, p)
break;
/*
- * Set interface name.
+ * Get interface name.
*/
case BIOCGETIF:
if (d->bd_bif == 0)
error = EINVAL;
- else
- bpf_ifname(d->bd_bif->bif_ifp, (struct ifreq *)addr);
+ else {
+ struct ifnet *const ifp = d->bd_bif->bif_ifp;
+ struct ifreq *const ifr = (struct ifreq *)addr;
+
+ snprintf(ifr->ifr_name, sizeof(ifr->ifr_name),
+ "%s%d", ifp->if_name, ifp->if_unit);
+ }
break;
/*
@@ -991,26 +995,6 @@ bpf_setif(d, ifr)
}
/*
- * Convert an interface name plus unit number of an ifp to a single
- * name which is returned in the ifr.
- */
-static void
-bpf_ifname(ifp, ifr)
- struct ifnet *ifp;
- struct ifreq *ifr;
-{
- char *s = ifp->if_name;
- char *d = ifr->ifr_name;
-
- while ((*d++ = *s++) != 0)
- continue;
- d--; /* back to the null */
- /* XXX Assume that unit number is less than 10. */
- *d++ = ifp->if_unit + '0';
- *d = '\0';
-}
-
-/*
* Support for select() and poll() system calls
*
* Return true iff the specific operation will not block indefinitely.
OpenPOWER on IntegriCloud