summaryrefslogtreecommitdiffstats
path: root/system/gdm/patches/gdm-2.20.11-crypt.diff
blob: 57860d39e6902675c01e020f84981caa0d0aa2d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
From cb04d3cb6b3899b5386f940a385d08c66dcd0da1 Mon Sep 17 00:00:00 2001
From: mancha <mancha1@hush.com>
Date: Fri, 31 Jan 2014
Subject: Handle new crypt() behavior in glibc 2.17+

Starting with glibc 2.17 (eglibc 2.17), crypt() fails with EINVAL
(w/ NULL return) if the salt violates specifications. Additionally,
on FIPS-140 enabled Linux systems, DES/MD5-encrypted passwords
passed to crypt() fail with EPERM (w/ NULL return).

If using glibc's crypt(), check return value to avoid a possible
NULL pointer dereference.

Note: gdm 2.20.11 is the last version that support non-PAM 
      authentication which is why it is the latest stable
      maintained for Slackware Linux via slackbuilds.org.

---
 daemon/verify-crypt.c  |   13 ++++++++++---
 daemon/verify-shadow.c |   13 ++++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

--- a/daemon/verify-crypt.c
+++ b/daemon/verify-crypt.c
@@ -104,7 +104,7 @@ gdm_verify_user (GdmDisplay *d,
 		 const char *username,
 		 gboolean allow_retry)
 {
-	gchar *login, *passwd, *ppasswd;
+	gchar *login, *passwd, *ppasswd, *cpasswd;
 	struct passwd *pwent;
 #if defined (HAVE_PASSWDEXPIRED) && defined (HAVE_CHPASS)	\
 	|| defined (HAVE_LOGINRESTRICTIONS)
@@ -190,8 +190,10 @@ gdm_verify_user (GdmDisplay *d,
 	}
 
 	/* Check whether password is valid */
-	if (ppasswd == NULL || (ppasswd[0] != '\0' &&
-				strcmp (crypt (passwd, ppasswd), ppasswd) != 0)) {
+	cpasswd = ppasswd ? g_strdup(crypt (passwd, ppasswd)) : NULL;
+	if (ppasswd == NULL || cpasswd == NULL ||
+				(ppasswd[0] != '\0' &&
+				 strcmp (cpasswd, ppasswd) != 0)) {
 		gdm_sleep_no_signal (gdm_daemon_config_get_value_int (GDM_KEY_RETRY_DELAY));
 		gdm_debug ("Couldn't authenticate user");
 
@@ -200,6 +202,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -217,6 +220,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -233,6 +237,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		if (message != NULL)
 			free (message);
 		return NULL;
@@ -259,6 +264,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -266,6 +272,7 @@ gdm_verify_user (GdmDisplay *d,
 
 	g_free (passwd);
 	g_free (ppasswd);
+	g_free (cpasswd);
 
 	if ( ! gdm_slave_check_user_wants_to_log_in (login)) {
 		g_free (login);
--- a/daemon/verify-shadow.c
+++ b/daemon/verify-shadow.c
@@ -105,7 +105,7 @@ gdm_verify_user (GdmDisplay *d,
 		 const char *username,
 		 gboolean allow_retry)
 {
-	gchar *login, *passwd, *ppasswd;
+	gchar *login, *passwd, *ppasswd, *cpasswd;
 	struct passwd *pwent;
 	struct spwd *sp;
 #if defined (HAVE_PASSWDEXPIRED) && defined (HAVE_CHPASS)	\
@@ -211,8 +211,10 @@ gdm_verify_user (GdmDisplay *d,
 	}
 
 	/* Check whether password is valid */
-	if (ppasswd == NULL || (ppasswd[0] != '\0' &&
-				strcmp (crypt (passwd, ppasswd), ppasswd) != 0)) {
+	cpasswd = ppasswd ? g_strdup(crypt (passwd, ppasswd)) : NULL;
+	if (ppasswd == NULL || cpasswd == NULL || 
+				(ppasswd[0] != '\0' &&
+				 strcmp (cpasswd, ppasswd) != 0)) {
 		gdm_sleep_no_signal (gdm_daemon_config_get_value_int (GDM_KEY_RETRY_DELAY));
 		gdm_debug ("Couldn't authenticate user");
 
@@ -221,6 +223,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -238,6 +241,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -254,6 +258,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		if (message != NULL)
 			free (message);
 		return NULL;
@@ -280,6 +285,7 @@ gdm_verify_user (GdmDisplay *d,
 		g_free (login);
 		g_free (passwd);
 		g_free (ppasswd);
+		g_free (cpasswd);
 		return NULL;
 	}
 
@@ -287,6 +293,7 @@ gdm_verify_user (GdmDisplay *d,
 
 	g_free (passwd);
 	g_free (ppasswd);
+	g_free (cpasswd);
 
 	if ( ! gdm_slave_check_user_wants_to_log_in (login)) {
 		g_free (login);