pppd: fix possible null pointer dereferencing

We shouldn't call strcmp directly on return value of crypt() because
it might return NULL.

Resolves: #815617

Conflicts:
	ppp.spec
This commit is contained in:
Michal Sekletar 2013-07-04 16:19:23 +02:00
parent e0acbf1f26
commit 7c61e74cd8
2 changed files with 53 additions and 1 deletions

47
ppp-2.4.5-crypt.patch Normal file
View File

@ -0,0 +1,47 @@
diff -up ppp-2.4.5/pppd/auth.c.crypt ppp-2.4.5/pppd/auth.c
--- ppp-2.4.5/pppd/auth.c.crypt 2013-07-04 16:10:27.338463397 +0200
+++ ppp-2.4.5/pppd/auth.c 2013-07-04 16:15:00.204471203 +0200
@@ -1515,11 +1515,19 @@ check_passwd(unit, auser, userlen, apass
ret = UPAP_AUTHNAK;
}
}
+
if (secret[0] != 0 && !login_secret) {
- /* password given in pap-secrets - must match */
- if ((cryptpap || strcmp(passwd, secret) != 0)
- && strcmp(crypt(passwd, secret), secret) != 0)
- ret = UPAP_AUTHNAK;
+ /* password given in pap-secrets - must match */
+ char *cryptbuf = NULL;
+ cryptbuf = crypt(passwd, secret);
+
+ if (cryptpap) {
+ if ((cryptbuf == NULL) || (strcmp(cryptbuf, secret) != 0))
+ ret = UPAP_AUTHNAK;
+ } else {
+ if ((strcmp(passwd, secret) != 0) && (cryptbuf == NULL || strcmp(cryptbuf, secret) != 0))
+ ret = UPAP_AUTHNAK;
+ }
}
}
fclose(f);
diff -up ppp-2.4.5/pppd/session.c.crypt ppp-2.4.5/pppd/session.c
--- ppp-2.4.5/pppd/session.c.crypt 2009-11-16 23:26:07.000000000 +0100
+++ ppp-2.4.5/pppd/session.c 2013-07-04 16:10:27.354463397 +0200
@@ -348,9 +348,14 @@ session_start(flags, user, passwd, ttyNa
/*
* If no passwd, don't let them login if we're authenticating.
*/
- if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2
- || strcmp(crypt(passwd, pw->pw_passwd), pw->pw_passwd) != 0)
+ if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2) {
return SESSION_FAILED;
+ } else {
+ char *cryptbuf = NULL;
+ cryptbuf = crypt(passwd, pw->pw_passwd);
+ if ((cryptbuf == NULL) || (strcmp(cryptbuf, pw->pw_passwd) != 0))
+ return SESSION_FAILED;
+ }
}
#endif /* #ifdef USE_PAM */

View File

@ -1,7 +1,7 @@
Summary: The Point-to-Point Protocol daemon
Name: ppp
Version: 2.4.5
Release: 29%{?dist}
Release: 30%{?dist}
License: BSD and LGPLv2+ and GPLv2+ and Public Domain
Group: System Environment/Daemons
URL: http://www.samba.org/ppp
@ -34,6 +34,7 @@ Patch30: ppp-2.4.5-eth.patch
Patch31: ppp-2.4.5-lock.patch
Patch32: ppp-2.4.5-l2tp-multilink.patch
Patch33: ppp-2.4.5-radius-config.patch
Patch34: ppp-2.4.5-crypt.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pam-devel, libpcap-devel, openssl-devel
@ -84,6 +85,7 @@ This package contains the header files for building plugins for ppp.
%patch31 -p1 -b .lock
%patch32 -p1 -b .l2tp-multilink
%patch33 -p1 -b .radius
%patch34 -p1 -b .crypt
rm -f scripts/*.local
rm -f scripts/*.change_resolv_conf
@ -158,6 +160,9 @@ install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/ppp
%doc PLUGINS
%changelog
* Thu Jul 04 2013 Michal Sekletar <msekleta@redhat.com> - 2.4.5-30
- fix possible NULL pointer dereferencing
* Wed May 29 2013 Michal Sekletar <msekleta@redhat.com> - 2.4.5-29
- make radius plugin config parser less strict
- resolves : #906913, #918296