- patch to remove gethostbyname() (bug #190296)

This commit is contained in:
Harald Hoyer 2006-05-08 15:15:57 +00:00
parent 3602889694
commit 39da061ce1
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,48 @@
--- netkit-telnet-0.17/telnet/commands.c.old 2006-04-30 10:24:49.000000000 -0700
+++ netkit-telnet-0.17/telnet/commands.c 2006-04-30 10:37:10.000000000 -0700
@@ -1669,9 +1669,15 @@
/* If this is not the full name, try to get it via DNS */
if (strchr(hbuf, '.') == 0) {
- struct hostent *he = gethostbyname(hbuf);
- if (he != 0)
- strncpy(hbuf, he->h_name, sizeof hbuf-1);
+ struct addrinfo hints;
+ struct addrinfo *res;
+ memset (&hints, '\0', sizeof (hints));
+ hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME;
+ if (getaddrinfo (hbuf, NULL, &hints, &res) == 0) {
+ if (res->ai_canonname != NULL)
+ strncpy(hbuf, res->ai_canonname, sizeof hbuf-1);
+ freeaddrinfo (res);
+ }
hbuf[sizeof hbuf-1] = '\0';
}
@@ -2832,17 +2838,15 @@
if (!c)
cp2 = 0;
- if ((tmp = inet_addr(cp)) != -1) {
- sin_addr.s_addr = tmp;
- } else if ((host = gethostbyname(cp))) {
-#if defined(h_addr)
- memmove((caddr_t)&sin_addr,
- host->h_addr_list[0],
- sizeof(sin_addr));
-#else
- memmove((caddr_t)&sin_addr, host->h_addr,
- sizeof(sin_addr));
-#endif
+ struct addrinfo hints;
+ memset (&hints, '\0', sizeof (hints));
+ // XXX The code here seems to allow only IPv4 addresses.
+ hints.ai_family = AF_INET;
+ hints.ai_flags = AI_ADDRCONFIG;
+ struct addrinfo *aires;
+ if (getaddrinfo (cp, NULL, &hints, &aires) == 0) {
+ sin_addr = ((struct sockaddr_in *) aires->ai_addr)->sin_addr;
+ freeaddrinfo (aires);
} else {
*cpp = cp;
return(0);

View File

@ -1,7 +1,7 @@
Summary: The client program for the telnet remote login protocol. Summary: The client program for the telnet remote login protocol.
Name: telnet Name: telnet
Version: 0.17 Version: 0.17
Release: 35.2.1 Release: 36
Epoch: 1 Epoch: 1
License: BSD License: BSD
Group: Applications/Internet Group: Applications/Internet
@ -22,6 +22,7 @@ Patch13: telnet-0.17-conf.patch
Patch14: telnet-0.17-cleanup_race.patch Patch14: telnet-0.17-cleanup_race.patch
Patch15: telnetd-0.17-pty_read.patch Patch15: telnetd-0.17-pty_read.patch
Patch16: telnet-0.17-CAN-2005-468_469.patch Patch16: telnet-0.17-CAN-2005-468_469.patch
Patch17: telnet-gethostbyname.patch
BuildPreReq: ncurses-devel BuildPreReq: ncurses-devel
Buildroot: %{_tmppath}/%{name}-root Buildroot: %{_tmppath}/%{name}-root
@ -60,6 +61,7 @@ mv telnet telnet-NETKIT
%patch14 -p1 -b .cleanup_race %patch14 -p1 -b .cleanup_race
%patch15 -p0 -b .pty_read %patch15 -p0 -b .pty_read
%patch16 -p1 -b .CAN-2005-468_469 %patch16 -p1 -b .CAN-2005-468_469
%patch17 -p1 -b .gethost
%build %build
export OPT_FLAGS="$RPM_OPT_FLAGS -g" export OPT_FLAGS="$RPM_OPT_FLAGS -g"
@ -125,6 +127,9 @@ rm -rf ${RPM_BUILD_ROOT}
%{_mandir}/man8/telnetd.8* %{_mandir}/man8/telnetd.8*
%changelog %changelog
* Mon May 08 2006 Harald Hoyer <harald@redhat.com> - 1:0.17-36
- patch to remove gethostbyname() (bug #190296)
* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 1:0.17-35.2.1 * Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 1:0.17-35.2.1
- bump again for double-long bug on ppc(64) - bump again for double-long bug on ppc(64)