docs/64291: inet_ntoa static buffer - man page ammendment

Lee Brotherston lee at nerds.org.uk
Mon Mar 15 10:00:37 UTC 2004


>Number:         64291
>Category:       docs
>Synopsis:       inet_ntoa static buffer - man page ammendment
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 15 02:00:35 PST 2004
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



More information about the freebsd-doc mailing list