Added patch to handle crypt() returning NULL

This commit is contained in:
Honza Horák 2012-04-26 12:37:10 +02:00
parent 55ad40a9b9
commit a71b90837c
2 changed files with 58 additions and 1 deletions

52
ypserv-2.27-crypt.patch Normal file
View File

@ -0,0 +1,52 @@
diff -up ypserv-2.27/rpc.yppasswdd/update.c.crypt ypserv-2.27/rpc.yppasswdd/update.c
--- ypserv-2.27/rpc.yppasswdd/update.c.crypt 2012-04-23 13:43:11.180743268 +0200
+++ ypserv-2.27/rpc.yppasswdd/update.c 2012-04-23 13:43:15.747726695 +0200
@@ -216,14 +216,27 @@ putspent_adjunct (const struct spwd *p,
/* Check if the password the user supplied matches the old one */
static int
-password_ok (char *plain, char *crypted, char *root)
+password_ok (char *plain, char *crypted, char *root, char *logbuf)
{
+ char *crypted_new;
if (crypted[0] == '\0')
return 1;
- if (strcmp (crypt (plain, crypted), crypted) == 0)
+ crypted_new = crypt (plain, crypted);
+ if (crypted_new == NULL)
+ {
+ log_msg ("crypt() call failed.", logbuf);
+ return 0;
+ }
+ if (strcmp (crypted_new, crypted) == 0)
return 1;
#if CHECKROOT
- if (strcmp (crypt (plain, root), root) == 0)
+ crypted_new = crypt (plain, root);
+ if (crypted_new == NULL)
+ {
+ log_msg ("crypt() call failed.", logbuf);
+ return 0;
+ }
+ if (strcmp (crypted_new, root) == 0)
return 1;
#endif
@@ -557,7 +570,7 @@ update_files (yppasswd *yppw, char *logb
{
if (strcmp (yppw->newpw.pw_name, spw->sp_namp) == 0)
{
- if (!password_ok (yppw->oldpass, spw->sp_pwdp, rootpass))
+ if (!password_ok (yppw->oldpass, spw->sp_pwdp, rootpass, logbuf))
{
log_msg ("%s rejected", logbuf);
log_msg ("Invalid password.");
@@ -579,7 +592,7 @@ update_files (yppasswd *yppw, char *logb
/* We don't have a shadow password file or we don't find the
user in it. */
if (spw == NULL &&
- !password_ok (yppw->oldpass, pw->pw_passwd, rootpass))
+ !password_ok (yppw->oldpass, pw->pw_passwd, rootpass, logbuf))
{
log_msg ("%s rejected", logbuf);
log_msg ("Invalid password.");

View File

@ -2,7 +2,7 @@ Summary: The NIS (Network Information Service) server
Url: http://www.linux-nis.org/nis/ypserv/index.html
Name: ypserv
Version: 2.27
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source0: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypserv-%{version}.tar.bz2
@ -33,6 +33,7 @@ Patch13: ypserv-2.26-errmsg.patch
Patch14: ypserv-2.26-emptydomain.patch
Patch16: ypserv-2.27-confpost.patch
Patch17: ypserv-2.27-cloexec.patch
Patch18: ypserv-2.27-crypt.patch
BuildRequires: compat-gdbm-devel
BuildRequires: systemd-units
@ -74,6 +75,7 @@ machines.
%patch14 -p1 -b .emptydomain
%patch16 -p1 -b .confpost
%patch17 -p1 -b .cloexec
%patch18 -p1 -b .crypt
autoreconf
@ -178,6 +180,9 @@ exit 0
%{_includedir}/*/*
%changelog
* Thu Apr 26 2012 Honza Horak <hhorak@redhat.com> - 2.27-3
- Added patch to handle crypt() returning NULL
* Fri Apr 13 2012 Honza Horak <hhorak@redhat.com> - 2.27-2
- Use O_CLOEXEC when opening pid file to avoid SELinux issues
Resolves: #809120