summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/rand.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2013-08-01 19:42:08 +0000
committerkettenis <kettenis@openbsd.org>2013-08-01 19:42:08 +0000
commit3d4cb4cc84bd9b3ac7ab97162eeaf2dd1c159f23 (patch)
treeb631a855fcfd7eb59aec27e6dc256effa37b6615 /lib/libc/stdlib/rand.c
parentmore set queue fallout fixups (diff)
downloadwireguard-openbsd-3d4cb4cc84bd9b3ac7ab97162eeaf2dd1c159f23.tar.xz
wireguard-openbsd-3d4cb4cc84bd9b3ac7ab97162eeaf2dd1c159f23.zip
Add linker warnings for rand() and random() and various related functions.
ok deraadt@
Diffstat (limited to 'lib/libc/stdlib/rand.c')
-rw-r--r--lib/libc/stdlib/rand.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 0f9c100807f..6860dd4f712 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -39,14 +39,29 @@ rand_r(u_int *seed)
return (*seed % ((u_int)RAND_MAX + 1));
}
+#if defined(APIWARN)
+__warn_references(rand_r,
+ "warning: rand_r() isn't random; consider using arc4random()");
+#endif
+
int
rand(void)
{
return (rand_r(&next));
}
+#if defined(APIWARN)
+__warn_references(rand,
+ "warning: rand() isn't random; consider using arc4random()");
+#endif
+
void
srand(u_int seed)
{
next = seed;
}
+
+#if defined(APIWARN)
+__warn_references(srand,
+ "warning: srand() seed choices are invariably poor");
+#endif