This is still an RC but the final version is supposed to come out in a couple of days. Committing early to catch regressions and all. Not much depends on this in ports anyway...
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
$OpenBSD: patch-kuser_generate-requests_c,v 1.2 2016/12/17 14:58:31 ajacoutot Exp $
|
|
|
|
Use HAVE_ARC4RANDOM and choose to call arc4random() instead of srand()
|
|
and rand() and friends.
|
|
|
|
--- kuser/generate-requests.c.orig Tue Nov 29 02:35:27 2016
|
|
+++ kuser/generate-requests.c Thu Dec 15 11:29:38 2016
|
|
@@ -67,7 +67,7 @@ generate_requests (const char *filename, unsigned nreq
|
|
krb5_context context;
|
|
krb5_error_code ret;
|
|
krb5_creds cred;
|
|
- int i;
|
|
+ int i, rnd;
|
|
char **words;
|
|
unsigned nwords;
|
|
|
|
@@ -78,7 +78,12 @@ generate_requests (const char *filename, unsigned nreq
|
|
nwords = read_words (filename, &words);
|
|
|
|
for (i = 0; i < nreq; ++i) {
|
|
- char *name = words[rand() % nwords];
|
|
+#ifdef HAVE_ARC4RANDOM
|
|
+ rnd = arc4random();
|
|
+#else
|
|
+ rnd = rand();
|
|
+#endif
|
|
+ char *name = words[rnd % nwords];
|
|
|
|
memset(&cred, 0, sizeof(cred));
|
|
|
|
@@ -137,7 +142,9 @@ main(int argc, char **argv)
|
|
|
|
if (argc != 2)
|
|
usage (1);
|
|
+#ifndef HAVE_ARC4RANDOM
|
|
srand (0);
|
|
+#endif
|
|
nreq = strtol (argv[1], &end, 0);
|
|
if (argv[1] == end || *end != '\0')
|
|
usage (1);
|