From ted@colanix0.ga.erg.sri.com  Mon Oct  6 11:08:37 2003
Return-Path: <ted@colanix0.ga.erg.sri.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D180516A4B3
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  6 Oct 2003 11:08:37 -0700 (PDT)
Received: from colanix0.ga.erg.sri.com (colanix0.ga.erg.sri.com [192.26.245.70])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E457643FD7
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  6 Oct 2003 11:08:36 -0700 (PDT)
	(envelope-from ted@colanix0.ga.erg.sri.com)
Received: from colanix0.ga.erg.sri.com (localhost [127.0.0.1])
	by colanix0.ga.erg.sri.com (8.12.3/8.12.3) with ESMTP id h96I8YSx019327;
	Mon, 6 Oct 2003 14:08:34 -0400 (EDT)
	(envelope-from ted@colanix0.ga.erg.sri.com)
Received: (from ted@localhost)
	by colanix0.ga.erg.sri.com (8.12.3/8.12.3/Submit) id h96I8Xds019326;
	Mon, 6 Oct 2003 14:08:33 -0400 (EDT)
Message-Id: <200310061808.h96I8Xds019326@colanix0.ga.erg.sri.com>
Date: Mon, 6 Oct 2003 14:08:33 -0400 (EDT)
From: Ted Nolan <ted@erg.sri.com>
Reply-To: Ted Nolan <ted@erg.sri.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: ted@erg.sri.com
Subject: IFMIB(4) man page uses sysctl(3) incorrectly in example code
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         57669
>Category:       docs
>Synopsis:       IFMIB(4) man page uses sysctl(3) incorrectly in example code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 06 11:10:10 PDT 2003
>Closed-Date:    Thu Dec 11 22:38:31 PST 2003
>Last-Modified:  Thu Dec 11 22:38:31 PST 2003
>Originator:     Ted Nolan
>Release:        FreeBSD 4.6.2-RELEASE i386
>Organization:
SRI International
>Environment:
System: FreeBSD colanix0 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Wed Aug 14 21:23:26 GMT 2002 murray@builder.freebsdmall.com:/usr/src/sys/compile/GENERIC i386


	
>Description:

The man page for ifmib(4) gives a code sample defining a function
get_ifmib_general().  This function uses the sysctl(3) function, but
with incorrect parameters.  The 4th parameter to sysctl(3) is the
_address_ of a location to read and store the size of the data;
however the example code places the actual size here, not the _location_
of the size.  The code will therefore give compilation warnings and
likely fail if run.

>How-To-Repeat:
Enter the code from the example, attempt to compile it with warnings
enabled.
>Fix:

One way to fix it would be to declare a variable
	size_t len;

and replace the given sysctl() line with 2 lines:

	len = sizeof(*ifmd);
	return sysctl(name, 6, ifmd, &len, (void *)0, 0);
>Release-Note:
>Audit-Trail:

From: Russell Francis <rf358197@ohio.edu>
To: freebsd-gnats-submit@FreeBSD.org, ted@erg.sri.com
Cc:  
Subject: Re: docs/57669: IFMIB(4) man page uses sysctl(3) incorrectly in example
 code
Date: Tue, 14 Oct 2003 07:19:53 -0400

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig058844B390B808621B29F43D
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 Ted,
 
 I saw your bug report at FreeBSD and thought I would let you know that
 the changes you suggested have allready been made.  If you cvsup a more
 recent version of FreeBSD you should see them.
 
 Thanks,
 Russ
 
 --------------enig058844B390B808621B29F43D
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.1 (FreeBSD)
 
 iD8DBQE/i9vil8gE/LToDToRAqLyAJ9gj14WNjLneiAGWcg+/lhMmfXysACgirW5
 e9gy2xu0b6sX4DQTi9p0Jqc=
 =wjMj
 -----END PGP SIGNATURE-----
 
 --------------enig058844B390B808621B29F43D--
 
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Thu Dec 11 22:37:38 PST 2003 
State-Changed-Why:  
johan has fixed this bug in -CURRENT and -STABLE. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=57669 
>Unformatted:
