From owner-svn-src-all@freebsd.org Sun Sep 13 01:31:18 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B43A9CC41B; Sun, 13 Sep 2015 01:31:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B89A1803; Sun, 13 Sep 2015 01:31:18 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8D1VImh056281; Sun, 13 Sep 2015 01:31:18 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8D1VIE2056280; Sun, 13 Sep 2015 01:31:18 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201509130131.t8D1VIE2056280@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Sun, 13 Sep 2015 01:31:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r287729 - stable/10/lib/libc/net X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Sep 2015 01:31:18 -0000 Author: hrs Date: Sun Sep 13 01:31:17 2015 New Revision: 287729 URL: https://svnweb.freebsd.org/changeset/base/287729 Log: MFC 287595: - Fix SIGSEGV when sa == NULL. NULL check in getnameinfo_inet() did not work as expected. - Simplify afdl table lookup. Modified: stable/10/lib/libc/net/getnameinfo.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/net/getnameinfo.c ============================================================================== --- stable/10/lib/libc/net/getnameinfo.c Sun Sep 13 00:08:04 2015 (r287728) +++ stable/10/lib/libc/net/getnameinfo.c Sun Sep 13 01:31:17 2015 (r287729) @@ -78,6 +78,8 @@ getnameinfo(const struct sockaddr *sa, s char *host, size_t hostlen, char *serv, size_t servlen, int flags) { + if (sa == NULL) + return (EAI_FAIL); switch (sa->sa_family) { case AF_INET: @@ -124,25 +126,19 @@ getnameinfo_inet(const struct sockaddr * struct servent *sp; struct hostent *hp; u_short port; - int family, i; const char *addr; u_int32_t v4a; int h_error; char numserv[512]; char numaddr[512]; - if (sa == NULL) - return EAI_FAIL; - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return EAI_FAMILY; + for (afd = &afdl[0]; afd->a_af > 0; afd++) { + if (afd->a_af == sa->sa_family) + break; + } + if (afd->a_af == 0) + return (EAI_FAMILY); - found: if (salen != afd->a_socklen) return EAI_FAIL;