aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2010-04-14 22:02:19 +0000
committerXin LI <delphij@FreeBSD.org>2010-04-14 22:02:19 +0000
commit57d848483eb9cb8a270e4355e4634ae940a7d7dd (patch)
tree90f64aecec4946da4408301a264d15000ddf0f0d /sys/net/if.c
parent410c7662749344645598007a28d70d283541347d (diff)
downloadsrc-57d848483eb9cb8a270e4355e4634ae940a7d7dd.tar.gz
src-57d848483eb9cb8a270e4355e4634ae940a7d7dd.zip
When an underlying ioctl(2) handler returns an error, our ioctl(2)
interface considers that it hits a fatal error, and will not copyout the request structure back for _IOW and _IOWR ioctls, keeping them untouched. The previous implementation of the SIOCGIFDESCR ioctl intends to feed the buffer length back to userland. However, if we return an error, the feedback would be defeated and ifconfig(8) would trap into an infinite loop. This commit changes SIOCGIFDESCR to set buffer field to NULL to indicate the previous ENAMETOOLONG case. Reported by: bschmidt MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=206637
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index e4a200549636..98c8afa4a2b9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2049,14 +2049,13 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
case SIOCGIFDESCR:
error = 0;
sx_slock(&ifdescr_sx);
- if (ifp->if_description == NULL) {
- ifr->ifr_buffer.length = 0;
+ if (ifp->if_description == NULL)
error = ENOMSG;
- } else {
+ else {
/* space for terminating nul */
descrlen = strlen(ifp->if_description) + 1;
if (ifr->ifr_buffer.length < descrlen)
- error = ENAMETOOLONG;
+ ifr->ifr_buffer.buffer = NULL;
else
error = copyout(ifp->if_description,
ifr->ifr_buffer.buffer, descrlen);