Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159542723
D8077.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D8077.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D8077: libc arc4_stir: use only kern.arandom sysctl
Attached
Detach File
Event Timeline
Log In to Comment