Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2012 21:00:30 GMT
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/161548: [patch] getent(1) inconsistent treatment of IPv6 host data
Message-ID:  <201203042100.q24L0UgT011481@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/161548; it has been noted by GNATS.

From: Matthew Seaman <m.seaman@infracaninophile.co.uk>
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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203042100.q24L0UgT011481>