Module Name: xsrc
Committed By: snj
Date: Tue Mar 7 21:00:47 UTC 2017
Modified Files:
xsrc/external/mit/libICE/dist/src [netbsd-6]: iceauth.c
xsrc/xfree/xc/lib/ICE [netbsd-6]: iceauth.c
Log Message:
Apply patch (requested by mrg in ticket #1442):
Use arc4random when available to produce the auth cookie.
(80f62c54fbd50a3bbdf9c37258525098c9117830 upstream)
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.3 -r1.1.1.3.2.1 \
xsrc/external/mit/libICE/dist/src/iceauth.c
cvs rdiff -u -r1.1.1.5 -r1.1.1.5.28.1 xsrc/xfree/xc/lib/ICE/iceauth.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: xsrc/external/mit/libICE/dist/src/iceauth.c
diff -u xsrc/external/mit/libICE/dist/src/iceauth.c:1.1.1.3 xsrc/external/mit/libICE/dist/src/iceauth.c:1.1.1.3.2.1
--- xsrc/external/mit/libICE/dist/src/iceauth.c:1.1.1.3 Sun Nov 21 05:47:12 2010
+++ xsrc/external/mit/libICE/dist/src/iceauth.c Tue Mar 7 21:00:47 2017
@@ -36,6 +36,10 @@ Author: Ralph Mor, X Consortium
#include <time.h>
#define Time_t time_t
+#ifdef HAVE_LIBBSD
+#include <bsd/stdlib.h> /* for arc4random_buf() */
+#endif
+
static int was_called_state;
/*
@@ -50,14 +54,19 @@ IceGenerateMagicCookie (
)
{
char *auth;
+#ifndef HAVE_ARC4RANDOM_BUF
long ldata[2];
int seed;
int value;
int i;
+#endif
if ((auth = (char *) malloc (len + 1)) == NULL)
return (NULL);
+#ifdef HAVE_ARC4RANDOM_BUF
+ arc4random_buf(auth, len);
+#else
#ifdef ITIMER_REAL
{
struct timeval now;
@@ -81,8 +90,8 @@ IceGenerateMagicCookie (
value = rand ();
auth[i] = value & 0xff;
}
+#endif
auth[len] = '\0';
-
return (auth);
}
Index: xsrc/xfree/xc/lib/ICE/iceauth.c
diff -u xsrc/xfree/xc/lib/ICE/iceauth.c:1.1.1.5 xsrc/xfree/xc/lib/ICE/iceauth.c:1.1.1.5.28.1
--- xsrc/xfree/xc/lib/ICE/iceauth.c:1.1.1.5 Fri Feb 28 13:18:45 2003
+++ xsrc/xfree/xc/lib/ICE/iceauth.c Tue Mar 7 21:00:47 2017
@@ -37,6 +37,10 @@ Author: Ralph Mor, X Consortium
static int binaryEqual ();
+#ifdef HAVE_LIBBSD
+#include <bsd/stdlib.h> /* for arc4random_buf() */
+#endif
+
static int was_called_state;
/*
@@ -52,14 +56,19 @@ int len;
{
char *auth;
+#ifndef HAVE_ARC4RANDOM_BUF
long ldata[2];
int seed;
int value;
int i;
+#endif
if ((auth = (char *) malloc (len + 1)) == NULL)
return (NULL);
+#ifdef HAVE_ARC4RANDOM_BUF
+ arc4random_buf(auth, len);
+#else
#ifdef ITIMER_REAL
{
struct timeval now;
@@ -83,8 +92,8 @@ int len;
value = rand ();
auth[i] = value & 0xff;
}
+#endif
auth[len] = '\0';
-
return (auth);
}