summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-25 21:20:13 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-06-25 21:20:13 +0000
commitc43fcaaef8b1a8b4e1860eb5329e32ba4d9d0ad6 (patch)
tree7622b57adc4062b4ce1d784947f0a3911bc8d5e7 /usr.bin
parentab174484018e75ef00e99c3f73be23ce9db3cdd4 (diff)
defn HAVE_ARC4RANDOM and use it
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/asn1_compile/Makefile4
-rw-r--r--usr.bin/asn1_compile/getarg.c9
2 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/asn1_compile/Makefile b/usr.bin/asn1_compile/Makefile
index bac8c42e759..5107ed45e1a 100644
--- a/usr.bin/asn1_compile/Makefile
+++ b/usr.bin/asn1_compile/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.2 2003/05/11 21:40:50 hin Exp $
+# $OpenBSD: Makefile,v 1.3 2003/06/25 21:20:12 deraadt Exp $
PROG= asn1_compile
NOMAN=
@@ -6,7 +6,7 @@ SRCS= parse.c lex.l main.c hash.c symbol.c gen.c \
gen_encode.c gen_decode.c gen_free.c gen_length.c gen_copy.c \
gen_glue.c getarg.c
-CFLAGS+=-I. -I$(.CURDIR) -DFALSE=0 -DTRUE=1
+CFLAGS+=-I. -I$(.CURDIR) -DFALSE=0 -DTRUE=1 -DHAVE_ARC4RANDOM
CLEANFILES= parse.[ch] lex.c
diff --git a/usr.bin/asn1_compile/getarg.c b/usr.bin/asn1_compile/getarg.c
index 65e9a604d12..86e9c447306 100644
--- a/usr.bin/asn1_compile/getarg.c
+++ b/usr.bin/asn1_compile/getarg.c
@@ -417,7 +417,9 @@ arg_match_long(struct getargs *args, size_t num_args,
*flag = !negate;
return 0;
} else if (*goptarg && strcmp(goptarg + 1, "maybe") == 0) {
-#ifdef HAVE_RANDOM
+#ifdef HAVE_ARC4RANDOM
+ *flag = arc4random() & 1;
+#elif HAVE_RANDOM
*flag = random() & 1;
#else
*flag = rand() & 1;
@@ -536,6 +538,8 @@ getarg(struct getargs *args, size_t num_args,
int i;
int ret = 0;
+#ifndef HAVE_ARC4RANDOM
+
#if defined(HAVE_SRANDOMDEV)
srandomdev();
#elif defined(HAVE_RANDOM)
@@ -543,6 +547,9 @@ getarg(struct getargs *args, size_t num_args,
#else
srand (time(NULL));
#endif
+
+#endif /* HAVE_ARC4RANDOM */
+
(*goptind)++;
for(i = *goptind; i < argc; i++) {
if(argv[i][0] != '-')