diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2016-10-05 17:03:22 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2016-10-05 17:03:22 +0000 |
| commit | 7e81ad1292587ce32b3a95291bc4e1fccd0de967 (patch) | |
| tree | e020c8e1528814698d2a752124a697c4c03e4a06 /lib | |
| parent | e7798d20c593f6c77866beb8f4e053fc9e1a253a (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/stdlib/random.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 2f5c5e1d478fd..f096aecb83359 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -270,16 +270,17 @@ void srandomdev(void) { int mib[2]; - size_t len; + size_t expected, len; if (rand_type == TYPE_0) - len = sizeof(state[0]); + expected = len = sizeof(state[0]); else - len = rand_deg * sizeof(state[0]); + expected = len = rand_deg * sizeof(state[0]); mib[0] = CTL_KERN; mib[1] = KERN_ARND; - sysctl(mib, 2, state, &len, NULL, 0); + if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) + abort(); if (rand_type != TYPE_0) { fptr = &state[rand_sep]; |
