diff options
author | matthew <> | 2014-06-20 00:02:12 +0000 |
---|---|---|
committer | matthew <> | 2014-06-20 00:02:12 +0000 |
commit | 038448a931f0b4209429847285e08acf69328612 (patch) | |
tree | 045608db3f2a62c96db0ddee7aed19cfbfd05e56 /src | |
parent | 150e8864673fb3b65a00e9188f50ca6a5bae927d (diff) | |
download | openbsd-038448a931f0b4209429847285e08acf69328612.tar.gz openbsd-038448a931f0b4209429847285e08acf69328612.tar.bz2 openbsd-038448a931f0b4209429847285e08acf69328612.zip |
arc4random: hard fail with raise(SIGKILL) if getentropy() returns -1
Allow other non-zero return values in case we change our mind to
return an ssize_t byte count instead of simple success/fail.
ok deraadt, djm
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/crypt/arc4random.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c index 985fa8a0e5..ea05d2a6e9 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.35 2014/06/19 00:13:22 matthew Exp $ */ | 1 | /* $OpenBSD: arc4random.c,v 1.36 2014/06/20 00:02:12 matthew Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> | 4 | * Copyright (c) 1996, David Mazieres <dm@uun.org> |
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include <fcntl.h> | 25 | #include <fcntl.h> |
26 | #include <limits.h> | 26 | #include <limits.h> |
27 | #include <signal.h> | ||
27 | #include <stdlib.h> | 28 | #include <stdlib.h> |
28 | #include <string.h> | 29 | #include <string.h> |
29 | #include <unistd.h> | 30 | #include <unistd.h> |
@@ -91,8 +92,8 @@ _rs_stir(void) | |||
91 | { | 92 | { |
92 | u_char rnd[KEYSZ + IVSZ]; | 93 | u_char rnd[KEYSZ + IVSZ]; |
93 | 94 | ||
94 | /* XXX */ | 95 | if (getentropy(rnd, sizeof rnd) == -1) |
95 | (void) getentropy(rnd, sizeof rnd); | 96 | raise(SIGKILL); |
96 | 97 | ||
97 | if (!rs) | 98 | if (!rs) |
98 | _rs_init(rnd, sizeof(rnd)); | 99 | _rs_init(rnd, sizeof(rnd)); |