Applied -gethost patch to check return value

(rhbz#698619)
This commit is contained in:
Honza Horák 2011-05-04 17:07:49 +02:00
parent 79b5fd34e0
commit ba4fef6209
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,33 @@
diff -up yp-tools-2.12/src/yppoll.c.gethost yp-tools-2.12/src/yppoll.c
--- yp-tools-2.12/src/yppoll.c.gethost 2001-12-08 20:59:10.000000000 +0100
+++ yp-tools-2.12/src/yppoll.c 2011-05-04 16:18:08.371772310 +0200
@@ -218,7 +218,10 @@ main (int argc, char **argv)
hent = gethostbyaddr ((char *)&clnt_saddr.sin_addr.s_addr,
sizeof (clnt_saddr.sin_addr.s_addr), AF_INET);
- hostname = strdup (hent->h_name);
+ if (hent)
+ {
+ hostname = strdup (hent->h_name);
+ }
}
else
{
@@ -261,7 +264,7 @@ main (int argc, char **argv)
&clnt_sock);
if (client == NULL)
{
- fprintf (stderr, _("Can't create connection to %s.\n"), hostname);
+ fprintf (stderr, _("Can't create connection to %s.\n"), hostname ? hostname : "unknown");
return 1;
}
@@ -279,7 +282,7 @@ main (int argc, char **argv)
if (clnt_res != TRUE)
{
fprintf (stdout, _("Domain %s is not supported by %s.\n"), domainname,
- hostname);
+ hostname ? hostname : "unknown");
return 1;
}

View File

@ -1,13 +1,14 @@
Summary: NIS (or YP) client programs
Name: yp-tools
Version: 2.12
Release: 5%{?dist}
Release: 6%{?dist}
License: GPLv2
Group: System Environment/Base
Source: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/yp-tools-%{version}.tar.bz2
# Not sent to upstream
Patch0: yp-tools-2.11-shadow.patch
Patch1: yp-tools-2.12-typo.patch
Patch2: yp-tools-2.12-gethost.patch
Url: http://www.linux-nis.org/nis/yp-tools/index.html
Requires: ypbind
@ -35,6 +36,7 @@ you'll need to install the ypserv package on one machine on the network.
%setup -q
%patch0 -p1 -b .shadow
%patch1 -p1 -b .typo
%patch2 -p1 -b .gethost
%build
%configure --disable-domainname
@ -56,6 +58,10 @@ make DESTDIR="$RPM_BUILD_ROOT" INSTALL_PROGRAM=install install
/var/yp/nicknames
%changelog
* Wed May 04 2011 Honza Horak <hhorak@redhat.com> - 2.12-6
- Applied -gethost patch to check return value
(rhbz#698619)
* Fri Mar 18 2011 Honza Horak <hhorak@redhat.com> - 2.12-5
- Applied -typo patch to fix a grammar mistake
(rhbz#668743)