aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/gen/arc4random.c11
-rw-r--r--lib/libc/stdlib/random.c9
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c
index 0fa3dff75cc9..becc17bc2711 100644
--- a/lib/libc/gen/arc4random.c
+++ b/lib/libc/gen/arc4random.c
@@ -144,8 +144,15 @@ arc4_stir(void)
arc4_init();
rs_initialized = 1;
}
- if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE)
- abort(); /* Random sysctl cannot fail. */
+ if (arc4_sysctl(rdat, KEYSIZE) != KEYSIZE) {
+ /*
+ * The sysctl cannot fail. If it does fail on some FreeBSD
+ * derivative or after some future change, just abort so that
+ * the problem will be found and fixed. abort is not normally
+ * suitable for a library but makes sense here.
+ */
+ abort();
+ }
arc4_addrandom(rdat, KEYSIZE);
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c
index f096aecb8335..48b120578698 100644
--- a/lib/libc/stdlib/random.c
+++ b/lib/libc/stdlib/random.c
@@ -279,8 +279,15 @@ srandomdev(void)
mib[0] = CTL_KERN;
mib[1] = KERN_ARND;
- if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected)
+ if (sysctl(mib, 2, state, &len, NULL, 0) == -1 || len != expected) {
+ /*
+ * The sysctl cannot fail. If it does fail on some FreeBSD
+ * derivative or after some future change, just abort so that
+ * the problem will be found and fixed. abort is not normally
+ * suitable for a library but makes sense here.
+ */
abort();
+ }
if (rand_type != TYPE_0) {
fptr = &state[rand_sep];