/[packages]/cauldron/x11-server/current/SOURCES/0003-Use-arc4random_buf-3-if-available-to-generate-cookie.patch
ViewVC logotype

Contents of /cauldron/x11-server/current/SOURCES/0003-Use-arc4random_buf-3-if-available-to-generate-cookie.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1088376 - (show annotations) (download)
Wed Mar 1 13:41:55 2017 UTC (7 years, 1 month ago) by tv
File size: 2332 byte(s)
security fix (CVE-2017-2624, mga#20376)
1 From ab15f65fe5d6d50e705c1064a6a5c1a0c2a8e045 Mon Sep 17 00:00:00 2001
2 From: Matthieu Herrb <matthieu@herrb.eu>
3 Date: Tue, 28 Feb 2017 19:18:43 +0100
4 Subject: [PATCH 3/4] Use arc4random_buf(3) if available to generate cookies.
5
6 Reviewed-by: Adam Jackson <ajax@redhat.com>
7 Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
8 (cherry picked from commit 957e8db38f27932d353e86e9aa69cf16778b18f1)
9 ---
10 configure.ac | 2 ++
11 include/dix-config.h.in | 6 ++++++
12 os/auth.c | 7 +++++++
13 3 files changed, 15 insertions(+)
14
15 diff --git a/configure.ac b/configure.ac
16 index 62cd547..610de09 100644
17 --- a/configure.ac
18 +++ b/configure.ac
19 @@ -225,6 +225,8 @@ AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\
20 timingsafe_memcmp])
21 AM_CONDITIONAL(POLL, [test "x$ac_cv_func_poll" = "xyes"])
22
23 +AC_CHECK_LIB([bsd], [arc4random_buf])
24 +
25 AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
26
27 dnl Check for SO_PEERCRED #define
28 diff --git a/include/dix-config.h.in b/include/dix-config.h.in
29 index 4b86c1a..d357910 100644
30 --- a/include/dix-config.h.in
31 +++ b/include/dix-config.h.in
32 @@ -125,6 +125,9 @@
33 /* Build a standalone xpbproxy */
34 #undef STANDALONE_XPBPROXY
35
36 +/* Define to 1 if you have the `bsd' library (-lbsd). */
37 +#undef HAVE_LIBBSD
38 +
39 /* Define to 1 if you have the `m' library (-lm). */
40 #undef HAVE_LIBM
41
42 @@ -161,6 +164,9 @@
43 /* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
44 #undef HAVE_RPCSVC_DBM_H
45
46 +/* Define to 1 if you have the `arc4random_buf' function. */
47 +#undef HAVE_ARC4RANDOM_BUF
48 +
49 /* Define to use libc SHA1 functions */
50 #undef HAVE_SHA1_IN_LIBC
51
52 diff --git a/os/auth.c b/os/auth.c
53 index 7da6fc6..81164a2 100644
54 --- a/os/auth.c
55 +++ b/os/auth.c
56 @@ -45,6 +45,9 @@ from The Open Group.
57 #ifdef WIN32
58 #include <X11/Xw32defs.h>
59 #endif
60 +#ifdef HAVE_LIBBSD
61 +#include <bsd/stdlib.h> /* for arc4random_buf() */
62 +#endif
63
64 struct protocol {
65 unsigned short name_length;
66 @@ -303,11 +306,15 @@ GenerateAuthorization(unsigned name_length,
67 void
68 GenerateRandomData(int len, char *buf)
69 {
70 +#ifdef HAVE_ARC4RANDOMBUF
71 + arc4random_buf(buf, len);
72 +#else
73 int fd;
74
75 fd = open("/dev/urandom", O_RDONLY);
76 read(fd, buf, len);
77 close(fd);
78 +#endif
79 }
80
81 #endif /* XCSECURITY */
82 --
83 2.10.2
84

  ViewVC Help
Powered by ViewVC 1.1.30