diff options
author | deraadt <> | 2014-12-09 08:00:53 +0000 |
---|---|---|
committer | deraadt <> | 2014-12-09 08:00:53 +0000 |
commit | 4c5fdbeac15beb0f782595a1add602427ab55614 (patch) | |
tree | 35bd17a9ae6153fa77f794ca4b3d4cbf07e50e54 /src | |
parent | dfd1c0c1d9d7c41d421ed649d2a4460b86132cb3 (diff) | |
download | openbsd-4c5fdbeac15beb0f782595a1add602427ab55614.tar.gz openbsd-4c5fdbeac15beb0f782595a1add602427ab55614.tar.bz2 openbsd-4c5fdbeac15beb0f782595a1add602427ab55614.zip |
improve warnings from rand_r(), rand(), and random()libressl-v2.1.2
It may take a few iterations to get the tone right.
previously discussed with millert
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/rand.c | 4 | ||||
-rw-r--r-- | src/lib/libc/stdlib/random.c | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c index 00390a23e7..ee2fd44bac 100644 --- a/src/lib/libc/stdlib/rand.c +++ b/src/lib/libc/stdlib/rand.c | |||
@@ -42,7 +42,7 @@ rand_r(u_int *seed) | |||
42 | 42 | ||
43 | #if defined(APIWARN) | 43 | #if defined(APIWARN) |
44 | __warn_references(rand_r, | 44 | __warn_references(rand_r, |
45 | "warning: rand_r() isn't random; consider using arc4random()"); | 45 | "warning: rand_r() is not random, it is deterministic."); |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | int | 48 | int |
@@ -55,7 +55,7 @@ rand(void) | |||
55 | 55 | ||
56 | #if defined(APIWARN) | 56 | #if defined(APIWARN) |
57 | __warn_references(rand, | 57 | __warn_references(rand, |
58 | "warning: rand() isn't random; consider using arc4random()"); | 58 | "warning: rand() may return determinstic values, is that what you want?"); |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | void | 61 | void |
diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c index cba088c751..375bfbd0e6 100644 --- a/src/lib/libc/stdlib/random.c +++ b/src/lib/libc/stdlib/random.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: random.c,v 1.25 2014/12/08 21:45:20 deraadt Exp $ */ | 1 | /* $OpenBSD: random.c,v 1.26 2014/12/09 08:00:53 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 1983 Regents of the University of California. | 3 | * Copyright (c) 1983 Regents of the University of California. |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -415,3 +415,8 @@ random(void) | |||
415 | UNLOCK(); | 415 | UNLOCK(); |
416 | return r; | 416 | return r; |
417 | } | 417 | } |
418 | |||
419 | #if defined(APIWARN) | ||
420 | __warn_references(rand, | ||
421 | "warning: random() may return determinstic values, is that what you want?"); | ||
422 | #endif | ||