diff options
author | kettenis <> | 2013-08-01 19:42:08 +0000 |
---|---|---|
committer | kettenis <> | 2013-08-01 19:42:08 +0000 |
commit | c19a4d8e475e9d51a75453e36ddf7463735e75e6 (patch) | |
tree | bb5b13c71f3c12127d56634b697afb75f42be74c /src/lib/libc/stdlib/rand.c | |
parent | a7956bb08f9d8d58fbd4669a4802b2d780efc2a1 (diff) | |
download | openbsd-c19a4d8e475e9d51a75453e36ddf7463735e75e6.tar.gz openbsd-c19a4d8e475e9d51a75453e36ddf7463735e75e6.tar.bz2 openbsd-c19a4d8e475e9d51a75453e36ddf7463735e75e6.zip |
Add linker warnings for rand() and random() and various related functions.
ok deraadt@
Diffstat (limited to 'src/lib/libc/stdlib/rand.c')
-rw-r--r-- | src/lib/libc/stdlib/rand.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c index 0f9c100807..6860dd4f71 100644 --- a/src/lib/libc/stdlib/rand.c +++ b/src/lib/libc/stdlib/rand.c | |||
@@ -39,14 +39,29 @@ rand_r(u_int *seed) | |||
39 | return (*seed % ((u_int)RAND_MAX + 1)); | 39 | return (*seed % ((u_int)RAND_MAX + 1)); |
40 | } | 40 | } |
41 | 41 | ||
42 | #if defined(APIWARN) | ||
43 | __warn_references(rand_r, | ||
44 | "warning: rand_r() isn't random; consider using arc4random()"); | ||
45 | #endif | ||
46 | |||
42 | int | 47 | int |
43 | rand(void) | 48 | rand(void) |
44 | { | 49 | { |
45 | return (rand_r(&next)); | 50 | return (rand_r(&next)); |
46 | } | 51 | } |
47 | 52 | ||
53 | #if defined(APIWARN) | ||
54 | __warn_references(rand, | ||
55 | "warning: rand() isn't random; consider using arc4random()"); | ||
56 | #endif | ||
57 | |||
48 | void | 58 | void |
49 | srand(u_int seed) | 59 | srand(u_int seed) |
50 | { | 60 | { |
51 | next = seed; | 61 | next = seed; |
52 | } | 62 | } |
63 | |||
64 | #if defined(APIWARN) | ||
65 | __warn_references(srand, | ||
66 | "warning: srand() seed choices are invariably poor"); | ||
67 | #endif | ||