From nobody@FreeBSD.org  Mon Mar 15 01:58:26 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1AC0E16A4ED
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Mar 2004 01:58:26 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 14BAB43D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Mar 2004 01:58:26 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i2F9wP72094021
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Mar 2004 01:58:25 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i2F9wPdP094019;
	Mon, 15 Mar 2004 01:58:25 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200403150958.i2F9wPdP094019@www.freebsd.org>
Date: Mon, 15 Mar 2004 01:58:25 -0800 (PST)
From: Lee Brotherston <lee@nerds.org.uk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: inet_ntoa static buffer - man page ammendment
X-Send-Pr-Version: www-2.3

>Number:         64291
>Category:       docs
>Synopsis:       inet_ntoa static buffer - man page ammendment
>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 Mar 15 02:00:35 PST 2004
>Closed-Date:    Tue Mar 23 04:20:48 PST 2004
>Last-Modified:  Tue Mar 23 04:20:48 PST 2004
>Originator:     Lee Brotherston
>Release:        FreeBSD 5.2.1-RELEASE
>Organization:
>Environment:
FreeBSD  5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #2: Mon Mar  8 03:32:49 GMT 2004     lee@:/usr/obj/usr/src/sys/MYKERN  i386
      
>Description:
The man page for inet_ntoa does not mention that is uses a static buffer.  It is perhaps worth mentioning this as further calls to inet_ntoa will overwrite the previous response.

Perhaps this should be obvious, however I just fell foul of this and thought clarification on the man page might be useful.
>How-To-Repeat:
The following section of code (where ip_hdr is a struct *ip) will log both addresses to be the same when they are not.  Presumably because both inet_ntoa's are evaluated before the log function is run.  As a result the first result has been lost.

log(LOG_INFO, "%s -> %s", inet_ntoa(ip_hdr->ip_src), inet_ntoa(ip_hdr->ip_dst));

>Fix:
Ammendment to the man page.  If it helps I found this version on a linux machines manpage:

The inet_ntoa() function converts the Internet host address  in  given  in  network byte  order  to  a  string  in  standard  numbers-and-dots notation.  The string is returned in a statically allocated buffer, which subsequent calls will overwrite.
>Release-Note:
>Audit-Trail:

From: Colin Percival <colin.percival@wadham.ox.ac.uk>
To: freebsd-gnats-submit@FreeBSD.org, lee@nerds.org.uk
Cc:  
Subject: Re: docs/64291: inet_ntoa static buffer - man page ammendment
Date: Tue, 23 Mar 2004 09:47:10 +0000

   Under BUGS, inet_ntoa(3) says:
 "The string returned by inet_ntoa() resides in a static memory area."
 
   Is this insufficient?  If so, what should it say?
 
 Colin Percival
 
State-Changed-From-To: open->closed 
State-Changed-By: cperciva 
State-Changed-When: Tue Mar 23 04:19:42 PST 2004 
State-Changed-Why:  
Submitter agrees that the existing documentation (in BUGS) is sufficient. 

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