diff options
| author | kettenis <> | 2013-08-01 19:42:08 +0000 |
|---|---|---|
| committer | kettenis <> | 2013-08-01 19:42:08 +0000 |
| commit | e263a6b48950a71c7a8df11538417524ff0f8164 (patch) | |
| tree | bb5b13c71f3c12127d56634b697afb75f42be74c /src/lib/libc/stdlib/rand.c | |
| parent | 5fe211b237cf424e65aabaa9829cb57a19103515 (diff) | |
| download | openbsd-e263a6b48950a71c7a8df11538417524ff0f8164.tar.gz openbsd-e263a6b48950a71c7a8df11538417524ff0f8164.tar.bz2 openbsd-e263a6b48950a71c7a8df11538417524ff0f8164.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 | ||
