Date: Mon, 15 Mar 2004 01:58:25 -0800 (PST) From: Lee Brotherston <lee@nerds.org.uk> To: freebsd-gnats-submit@FreeBSD.org Subject: docs/64291: inet_ntoa static buffer - man page ammendment Message-ID: <200403150958.i2F9wPdP094019@www.freebsd.org> Resent-Message-ID: <200403151000.i2FA0Zah093637@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403150958.i2F9wPdP094019>