Page MenuHomeFreeBSD

D8077.diff
No OneTemporary

D8077.diff

Index: head/lib/libc/gen/arc4random.c
===================================================================
--- head/lib/libc/gen/arc4random.c
+++ head/lib/libc/gen/arc4random.c
@@ -137,35 +137,17 @@
static void
arc4_stir(void)
{
- int done, fd, i;
- struct {
- struct timeval tv;
- pid_t pid;
- u_char rnd[KEYSIZE];
- } rdat;
+ u_char rdat[KEYSIZE];
+ int i;
if (!rs_initialized) {
arc4_init();
rs_initialized = 1;
}
- done = 0;
- if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE)
- done = 1;
- if (!done) {
- fd = _open(RANDOMDEV, O_RDONLY | O_CLOEXEC, 0);
- if (fd >= 0) {
- if (_read(fd, &rdat, KEYSIZE) == KEYSIZE)
- done = 1;
- (void)_close(fd);
- }
- }
- if (!done) {
- (void)gettimeofday(&rdat.tv, NULL);
- rdat.pid = getpid();
- /* We'll just take whatever was on the stack too... */
- }
+ if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE)
+ abort(); /* Random sysctl cannot fail. */
- arc4_addrandom((u_char *)&rdat, KEYSIZE);
+ arc4_addrandom(rdat, KEYSIZE);
/*
* Discard early keystream, as per recommendations in:

File Metadata

Mime Type
text/plain
Expires
Tue, Jun 16, 1:39 PM (14 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33988424
Default Alt Text
D8077.diff (1 KB)

Event Timeline