summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-04-14 22:02:19 +0000
committerdelphij <delphij@FreeBSD.org>2010-04-14 22:02:19 +0000
commit58be1647f81d964462a1ca747976a7a85714fc0b (patch)
tree90f64aecec4946da4408301a264d15000ddf0f0d /sbin
parentd7c34a15b8684c6d9333e40ee8de208dfd3ae3e3 (diff)
downloadFreeBSD-src-58be1647f81d964462a1ca747976a7a85714fc0b.zip
FreeBSD-src-58be1647f81d964462a1ca747976a7a85714fc0b.tar.gz
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
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifconfig.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 7af3306..aa96175 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -922,19 +922,20 @@ status(const struct afswtch *afp, const struct sockaddr_dl *sdl,
ifr.ifr_buffer.buffer = descr;
ifr.ifr_buffer.length = descrlen;
if (ioctl(s, SIOCGIFDESCR, &ifr) == 0) {
- if (strlen(descr) > 0)
- printf("\tdescription: %s\n", descr);
- break;
- } else if (errno == ENAMETOOLONG)
- descrlen = ifr.ifr_buffer.length;
- else
- break;
- } else {
+ if (ifr.ifr_buffer.buffer == descr) {
+ if (strlen(descr) > 0)
+ printf("\tdescription: %s\n",
+ descr);
+ } else if (ifr.ifr_buffer.length > descrlen) {
+ descrlen = ifr.ifr_buffer.length;
+ continue;
+ }
+ }
+ } else
warn("unable to allocate memory for interface"
"description");
- break;
- }
- };
+ break;
+ }
if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) == 0) {
if (ifr.ifr_curcap != 0) {
OpenPOWER on IntegriCloud