From owner-freebsd-bugs@FreeBSD.ORG Sun Mar 4 21:00:30 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AB0D4106566B for ; Sun, 4 Mar 2012 21:00:30 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 948868FC08 for ; Sun, 4 Mar 2012 21:00:30 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q24L0U9L011482 for ; Sun, 4 Mar 2012 21:00:30 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q24L0UgT011481; Sun, 4 Mar 2012 21:00:30 GMT (envelope-from gnats) Date: Sun, 4 Mar 2012 21:00:30 GMT Message-Id: <201203042100.q24L0UgT011481@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Matthew Seaman Cc: Subject: Re: bin/161548: [patch] getent(1) inconsistent treatment of IPv6 host data X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthew Seaman List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Mar 2012 21:00:30 -0000 The following reply was made to PR bin/161548; it has been noted by GNATS. From: Matthew Seaman To: bug-followup@FreeBSD.org, m.seaman@infracaninophile.co.uk Cc: Subject: Re: bin/161548: [patch] getent(1) inconsistent treatment of IPv6 host data Date: Sun, 04 Mar 2012 20:54:46 +0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB21C0AF02D70136FAF89589A Content-Type: multipart/mixed; boundary="------------060107050309040500000709" This is a multi-part message in MIME format. --------------060107050309040500000709 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable This fixes a potential use-before-initialization problem and compiles with clang. --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------060107050309040500000709 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="getent.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="getent.diff" Index: usr.bin/getent/getent.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- usr.bin/getent/getent.c (revision 232455) +++ usr.bin/getent/getent.c (working copy) @@ -277,7 +277,7 @@ static int hosts(int argc, char *argv[]) { - struct hostent *he; + struct hostent *he4 =3D NULL, *he6 =3D NULL; char addr[IN6ADDRSZ]; int i, rv; =20 @@ -287,19 +287,27 @@ sethostent(1); rv =3D RV_OK; if (argc =3D=3D 2) { - while ((he =3D gethostent()) !=3D NULL) - hostsprint(he); + while ((he4 =3D gethostent()) !=3D NULL) + hostsprint(he4); } else { for (i =3D 2; i < argc; i++) { - if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) - he =3D gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); - else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) - he =3D gethostbyaddr(addr, INADDRSZ, AF_INET); - else - he =3D gethostbyname(argv[i]); - if (he !=3D NULL) - hostsprint(he); - else { + if (inet_pton(AF_INET6, argv[i], (void *)addr) > 0) { + he6 =3D gethostbyaddr(addr, IN6ADDRSZ, AF_INET6); + if (he6 !=3D NULL) + hostsprint(he6); + } else if (inet_pton(AF_INET, argv[i], (void *)addr) > 0) { + he4 =3D gethostbyaddr(addr, INADDRSZ, AF_INET); + if (he4 !=3D NULL) + hostsprint(he4); + } else { + he6 =3D gethostbyname2(argv[i], AF_INET6); + if (he6 !=3D NULL) + hostsprint(he6); + he4 =3D gethostbyname(argv[i]); + if (he4 !=3D NULL) + hostsprint(he4); + } + if ( he4 =3D=3D NULL && he6 =3D=3D NULL ) { rv =3D RV_NOTFOUND; break; } --------------060107050309040500000709-- --------------enigB21C0AF02D70136FAF89589A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9T1pYACgkQ8Mjk52CukIwfigCfepp3/RXcKSGyYXkgNkk7SzeR vggAn3izHRpHjGBnWQvvv46L45CQAO63 =vXZ1 -----END PGP SIGNATURE----- --------------enigB21C0AF02D70136FAF89589A--