rpms/iputils/F-11 iputils-20071127-hostbyname.patch, NONE, 1.1 iputils.spec, 1.65, 1.66

Jiri Skala jskala at fedoraproject.org
Wed Sep 9 09:24:01 UTC 2009


Author: jskala

Update of /cvs/extras/rpms/iputils/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv31879

Modified Files:
	iputils.spec 
Added Files:
	iputils-20071127-hostbyname.patch 
Log Message:
* Wed Sep 09 2009 Jiri Skala <jskala at redhat.com> - 20071127-9
- fixed #516179  - gethostbyname replaced by getaddrinfo


iputils-20071127-hostbyname.patch:
 ping.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

--- NEW FILE iputils-20071127-hostbyname.patch ---
diff -up iputils-s20071127/ping.c.hostbyname iputils-s20071127/ping.c
--- iputils-s20071127/ping.c.hostbyname	2009-09-09 09:49:26.009173503 +0200
+++ iputils-s20071127/ping.c	2009-09-09 11:12:28.250128341 +0200
@@ -118,7 +118,7 @@ int pmtudisc = -1;
 int
 main(int argc, char **argv)
 {
-	struct hostent *hp;
+	struct addrinfo hints, *res;
 	int ch, hold, packlen;
 	int socket_errno;
 	u_char *packet;
@@ -258,25 +258,30 @@ main(int argc, char **argv)
 		} else {
 			rc = idna_to_ascii_lz (target, &idn, 0);
 			if (rc == IDNA_SUCCESS)
-				hp = gethostbyname (idn);
-			else {
+			{
+				memset(&hints, 0, sizeof(hints));
+				hints.ai_family = AF_INET;
+				hints.ai_flags = AI_CANONNAME;
+				rc = getaddrinfo(idn, NULL, &hints, &res);
+			} else {
 				fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
 				exit(2);
 			}
 			free(idn);
-			if (!hp) {
+			if (!res || rc) {
 				fprintf(stderr, "ping: unknown host %s\n", target);
 				exit(2);
 			}
-			memcpy(&whereto.sin_addr, hp->h_addr, 4);
-			rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
+			whereto.sin_addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr;
+			rc = idna_to_unicode_lzlz (target, &idn, 0);
 			if (rc == IDNA_SUCCESS)
 				strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
 			else {
-				fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
+				fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
 				exit(2);
 			}
 			free(idn);
+			freeaddrinfo(res);
 			hnamebuf[sizeof(hnamebuf) - 1] = 0;
 			hostname = hnamebuf;
 		}


Index: iputils.spec
===================================================================
RCS file: /cvs/extras/rpms/iputils/F-11/iputils.spec,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -p -r1.65 -r1.66
--- iputils.spec	25 Feb 2009 21:59:39 -0000	1.65
+++ iputils.spec	9 Sep 2009 09:24:01 -0000	1.66
@@ -1,7 +1,7 @@
 Summary: Network monitoring tools including ping
 Name: iputils
 Version: 20071127
-Release: 8%{?dist}
+Release: 9%{?dist}
 License: BSD
 URL: http://www.skbuff.net/iputils
 Group: System Environment/Daemons
@@ -26,6 +26,7 @@ Patch12: iputils-20070202-ia64_align.pat
 Patch13: iputils-20071127-warnings.patch
 Patch14: iputils-20071127-typing_bug.patch
 Patch15: iputils-20071127-corr_type.patch
+Patch16: iputils-20071127-hostbyname.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: docbook-utils perl-SGMLSpm
@@ -61,6 +62,7 @@ the target machine is alive and receivin
 %patch13 -p1 -b .warnings
 %patch14 -p1 -b .typing_bug
 %patch15 -p1 -b .corr_type
+%patch16 -p1 -b .hostbyname
 
 %build
 %ifarch s390 s390x
@@ -150,6 +152,9 @@ rm -rf ${RPM_BUILD_ROOT}
 %{_sysconfdir}/rc.d/init.d/rdisc
 
 %changelog
+* Wed Sep 09 2009 Jiri Skala <jskala at redhat.com> - 20071127-9
+- fixed #516179  - gethostbyname replaced by getaddrinfo
+
 * Wed Feb 25 2009 Jiri Skala <jskala at redhat.com> - 20071127-8
 - remake type conversions to gcc4.4 requirements
 




More information about the scm-commits mailing list