Module Name: xsrc Committed By: snj Date: Tue Mar 7 20:16:34 UTC 2017
Modified Files: xsrc/xfree/xc/lib/ICE [netbsd-7]: iceauth.c Log Message: Apply patch (requested by mrg in ticket #1380): Use arc4random when available to produce the auth cookie. (80f62c54fbd50a3bbdf9c37258525098c9117830 upstream) To generate a diff of this commit: cvs rdiff -u -r1.1.1.5 -r1.1.1.5.38.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/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.38.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 20:16:34 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); }