diff options
author | otto <> | 2005-11-30 07:51:02 +0000 |
---|---|---|
committer | otto <> | 2005-11-30 07:51:02 +0000 |
commit | f8452f05564b5820c3745b9348d85a2b3a745467 (patch) | |
tree | 803b53c012ae878cdf973f67d5346e2452f9e177 /src/lib/libc/crypt | |
parent | 75ccbec66ef4157baa8c840a64a98a73287280fb (diff) | |
download | openbsd-f8452f05564b5820c3745b9348d85a2b3a745467.tar.gz openbsd-f8452f05564b5820c3745b9348d85a2b3a745467.tar.bz2 openbsd-f8452f05564b5820c3745b9348d85a2b3a745467.zip |
Use sysctl(KERN_ARND) to get n bytes, instead of just 4 at a time
and remove fallback code. If somebody is dumb enough to make the
sysctl fail using systrace, he deserves what he gets. Saves 7 syscalls
on process startup.
looks good miod@ ok deraadt@ tedu@
Diffstat (limited to 'src/lib/libc/crypt')
-rw-r--r-- | src/lib/libc/crypt/arc4random.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c index 843751d09e..1e338f9968 100644 --- a/src/lib/libc/crypt/arc4random.c +++ b/src/lib/libc/crypt/arc4random.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: arc4random.c,v 1.14 2005/06/06 14:57:59 kjell Exp $ */ | 1 | /* $OpenBSD: arc4random.c,v 1.15 2005/11/30 07:51:02 otto Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> |
@@ -99,14 +99,7 @@ arc4_stir(struct arc4_stream *as) | |||
99 | mib[1] = KERN_ARND; | 99 | mib[1] = KERN_ARND; |
100 | 100 | ||
101 | len = sizeof(rnd); | 101 | len = sizeof(rnd); |
102 | if (sysctl(mib, 2, rnd, &len, NULL, 0) == -1) { | 102 | sysctl(mib, 2, rnd, &len, NULL, 0); |
103 | for (i = 0; i < sizeof(rnd) / sizeof(u_int); i ++) { | ||
104 | len = sizeof(u_int); | ||
105 | if (sysctl(mib, 2, &rnd[i * sizeof(u_int)], &len, | ||
106 | NULL, 0) == -1) | ||
107 | break; | ||
108 | } | ||
109 | } | ||
110 | 103 | ||
111 | arc4_stir_pid = getpid(); | 104 | arc4_stir_pid = getpid(); |
112 | arc4_addrandom(as, rnd, sizeof(rnd)); | 105 | arc4_addrandom(as, rnd, sizeof(rnd)); |