summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-support/ntp/files/ntp-4.2.6p5-cve-2014-9293.patch
blob: 667b705eaf2a3e1a8d80c5301fc963e2a4fd2137 (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
CVE-2014-9293 ntp: automatic generation of weak default key in config_auth()

Upstream-Status: Backport [Debian]

Signed-off-by: Armin Kuster <akuster808@gmail.com>

Index: git/ntpd/ntp_config.c
===================================================================
--- git.orig/ntpd/ntp_config.c	2014-12-20 18:45:45.232872120 +0100
+++ git/ntpd/ntp_config.c	2014-12-20 18:45:47.672921968 +0100
@@ -1866,13 +1866,16 @@
 		req_hashlen = digest_len;
 #endif
 	} else {
-		int	rankey;
+		unsigned char rankey[16];
+
+		if (ntp_crypto_random_buf(rankey, sizeof (rankey))) {
+			msyslog(LOG_ERR, "ntp_crypto_random_buf() failed.");
+			exit(1);
+		}
 
-		rankey = ntp_random();
 		req_keytype = NID_md5;
 		req_hashlen = 16;
-		MD5auth_setkey(req_keyid, req_keytype,
-		    (u_char *)&rankey, sizeof(rankey));
+		MD5auth_setkey(req_keyid, req_keytype, rankey, sizeof(rankey));
 		authtrust(req_keyid, 1);
 	}
 
Index: git/ntpd/ntpd.c
===================================================================
--- git.orig/ntpd/ntpd.c	2014-12-20 18:45:45.232872120 +0100
+++ git/ntpd/ntpd.c	2014-12-20 18:45:47.672921968 +0100
@@ -597,6 +597,7 @@
 	get_systime(&now);
 
 	ntp_srandom((int)(now.l_i * now.l_uf));
+	ntp_crypto_srandom();
 
 #if !defined(VMS)
 # ifndef NODETACH