Date: Thu, 21 Sep 2017 10:16:25 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r323857 - stable/11/lib/libc/net Message-ID: <201709211016.v8LAGPqb073014@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Thu Sep 21 10:16:25 2017 New Revision: 323857 URL: https://svnweb.freebsd.org/changeset/base/323857 Log: MFC r323597: Handle freeaddrinfo(NULL). Modified: stable/11/lib/libc/net/getaddrinfo.3 stable/11/lib/libc/net/getaddrinfo.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/net/getaddrinfo.3 ============================================================================== --- stable/11/lib/libc/net/getaddrinfo.3 Thu Sep 21 10:14:43 2017 (r323856) +++ stable/11/lib/libc/net/getaddrinfo.3 Thu Sep 21 10:16:25 2017 (r323857) @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2015 +.Dd September 13, 2017 .Dt GETADDRINFO 3 .Os .Sh NAME @@ -351,6 +351,17 @@ pointer should be a .Li addrinfo structure created by a call to .Fn getaddrinfo . +.Sh IMPLEMENTATION NOTES +The behavior of +.Li freeadrinfo(NULL) +is left unspecified by both +.St -susv4 +and +.Dv "RFC 3493" . +The current implementation ignores a +.Dv NULL +argument for compatibility with programs that rely on the implementation +details of other operating systems. .Sh RETURN VALUES .Fn getaddrinfo returns zero on success or one of the error codes listed in Modified: stable/11/lib/libc/net/getaddrinfo.c ============================================================================== --- stable/11/lib/libc/net/getaddrinfo.c Thu Sep 21 10:14:43 2017 (r323856) +++ stable/11/lib/libc/net/getaddrinfo.c Thu Sep 21 10:16:25 2017 (r323857) @@ -35,7 +35,7 @@ * in the source code. This is because RFC2553 is silent about which error * code must be returned for which situation. * - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is - * invalid. current code - SEGV on freeaddrinfo(NULL) + * invalid. Current code accepts NULL to be compatible with other OSes. * * Note: * - The code filters out AFs that are not supported by the kernel, @@ -359,14 +359,13 @@ freeaddrinfo(struct addrinfo *ai) { struct addrinfo *next; - do { + while (ai != NULL) { next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); + free(ai->ai_canonname); /* no need to free(ai->ai_addr) */ free(ai); ai = next; - } while (ai); + } } static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709211016.v8LAGPqb073014>