From owner-freebsd-hackers Wed Jan 10 3:10:47 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from citadel.cequrux.com (citadel.cequrux.com [192.96.22.18]) by hub.freebsd.org (Postfix) with ESMTP id 7E8F937B400 for ; Wed, 10 Jan 2001 03:10:22 -0800 (PST) Received: (from nobody@localhost) by citadel.cequrux.com (8.8.8/8.6.9) id NAA22906; Wed, 10 Jan 2001 13:10:02 +0200 (SAST) Received: by citadel.cequrux.com via recvmail id 22757; Wed Jan 10 13:08:57 2001 Message-ID: <3A5C2A87.C7591D2B@cequrux.com> Date: Wed, 10 Jan 2001 11:25:27 +0200 From: Graham Wheeler Organization: Cequrux Technologies X-Mailer: Mozilla 4.75 [en] (X11; U; FreeBSD 3.4-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: David Malone , freebsd-hackers@freebsd.org Subject: Re: Size of struct ifreq/returned buffer of SIOCGIFCONF References: <3A5AE854.F769B86C@cequrux.com> <20010109142043.B52761@walton.maths.tcd.ie> <3A5B148A.5F139188@cequrux.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Graham Wheeler wrote: > > David Malone wrote: > > > > If you read the paragraph below that code, it notes that the ifreq > > structures are of variable length. The spacing depends on the size > > of the returned info. > > That's true. In which case the cheops code is wrong, as it iterates > through the list by incrementing a pointer to a struct ifreq. I'll try > fix that and get Mark to test under Linux and hopefully get a portable > solution. Interestingly enough, a similar bug probably once existed in sysinstall. In /usr/src/release/sysinstall/devices.c, routine deviceGetAll(), there is a loop through these structures which also erroneously uses ++ to increment the struct ifreq* pointer. At the end of the loop, after the label loopend:, there is a line of code that fixes the pointer, together with a comment "I'm not sure why this is here - it's inherited". gr. -- Dr Graham Wheeler E-mail: gram@cequrux.com Director, Research and Development WWW: http://www.cequrux.com CEQURUX Technologies Phone: +27(21)423-6065 Firewalls/VPN Specialists Fax: +27(21)424-3656 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message