summary refs log tree commit diff
path: root/gnu/packages/patches/slock-CVE-2016-6866.patch
blob: 2f94b8c1a9062c8d2e137b157deee08ca869073e (plain) (blame)
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
Fix CVE-2016-6866.

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6866
https://security-tracker.debian.org/tracker/CVE-2016-6866

Copied from upstream source repository:
http://git.suckless.org/slock/commit/?id=d8bec0f6fdc8a246d78cb488a0068954b46fcb29

From d8bec0f6fdc8a246d78cb488a0068954b46fcb29 Mon Sep 17 00:00:00 2001
From: Markus Teich <markus.teich@stusta.mhn.de>
Date: Tue, 30 Aug 2016 22:59:06 +0000
Subject: fix CVE-2016-6866

---
diff --git a/slock.c b/slock.c
index 847b328..8ed59ca 100644
--- a/slock.c
+++ b/slock.c
@@ -123,7 +123,7 @@ readpw(Display *dpy)
 readpw(Display *dpy, const char *pws)
 #endif
 {
-	char buf[32], passwd[256];
+	char buf[32], passwd[256], *encrypted;
 	int num, screen;
 	unsigned int len, color;
 	KeySym ksym;
@@ -159,7 +159,11 @@ readpw(Display *dpy, const char *pws)
 #ifdef HAVE_BSD_AUTH
 				running = !auth_userokay(getlogin(), NULL, "auth-slock", passwd);
 #else
-				running = !!strcmp(crypt(passwd, pws), pws);
+				errno = 0;
+				if (!(encrypted = crypt(passwd, pws)))
+					fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
+				else
+					running = !!strcmp(encrypted, pws);
 #endif
 				if (running) {
 					XBell(dpy, 100);
@@ -312,6 +316,8 @@ main(int argc, char **argv) {
 
 #ifndef HAVE_BSD_AUTH
 	pws = getpw();
+	if (strlen(pws) < 2)
+		die("slock: failed to get user password hash.\n");
 #endif
 
 	if (!(dpy = XOpenDisplay(NULL)))
--
cgit v0.9.0.3-65-g4555