summaryrefslogtreecommitdiff
path: root/system/ksh-openbsd/patches/linux/var_c.diff
blob: 9483a3b4cedafb697e8860510fda2cb8886d8cd9 (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
44
45
46
47
48
49
50
51
52
53
--- ksh-openbsd_cvs/var.c	2010-02-23 12:49:23.000000000 +0100
+++ ksh-openbsd_cvs.new/var.c	2010-04-01 21:01:24.145380963 +0200
@@ -5,6 +5,7 @@
 #include "ksh_limval.h"
 #include <sys/stat.h>
 #include <ctype.h>
+#include "strlcpy.h"
 
 /*
  * Variables
@@ -865,12 +866,6 @@ makenv(void)
 }
 
 /*
- * Someone has set the srand() value, therefore from now on
- * we return values from rand() instead of arc4random()
- */
-int use_rand = 0;
-
-/*
  * Called after a fork in parent to bump the random number generator.
  * Done to ensure children will not get the same random number sequence
  * if the parent doesn't use $RANDOM.
@@ -878,8 +873,7 @@ int use_rand = 0;
 void
 change_random(void)
 {
-	if (use_rand)
-		rand();
+	rand();
 }
 
 /*
@@ -926,10 +920,7 @@ getspec(struct tbl *vp)
 		break;
 	case V_RANDOM:
 		vp->flag &= ~SPECIAL;
-		if (use_rand)
-			setint(vp, (long) (rand() & 0x7fff));
-		else
-			setint(vp, (long) (arc4random() & 0x7fff));
+		setint(vp, (long) (rand() & 0x7fff));
 		vp->flag |= SPECIAL;
 		break;
 #ifdef HISTORY
@@ -1030,7 +1021,6 @@ setspec(struct tbl *vp)
 	case V_RANDOM:
 		vp->flag &= ~SPECIAL;
 		srand((unsigned int)intval(vp));
-		use_rand = 1;
 		vp->flag |= SPECIAL;
 		break;
 	case V_SECONDS: