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/random.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/random.c')
| -rw-r--r-- | src/lib/libc/stdlib/random.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c index f299d8e2f6..00edf2dca1 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.18 2013/03/15 19:07:53 tedu Exp $ */ | 1 | /* $OpenBSD: random.c,v 1.19 2013/08/01 19:42:08 kettenis 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. |
| @@ -233,6 +233,11 @@ srandom(unsigned int x) | |||
| 233 | UNLOCK(); | 233 | UNLOCK(); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | #if defined(APIWARN) | ||
| 237 | __warn_references(srandom, | ||
| 238 | "warning: srandom() seed choices are invariably poor"); | ||
| 239 | #endif | ||
| 240 | |||
| 236 | /* | 241 | /* |
| 237 | * srandomdev: | 242 | * srandomdev: |
| 238 | * | 243 | * |
| @@ -267,6 +272,11 @@ srandomdev(void) | |||
| 267 | UNLOCK(); | 272 | UNLOCK(); |
| 268 | } | 273 | } |
| 269 | 274 | ||
| 275 | #if defined(APIWARN) | ||
| 276 | __warn_references(srandomdev, | ||
| 277 | "warning: srandomdev() usage; consider switching to arc4random()"); | ||
| 278 | #endif | ||
| 279 | |||
| 270 | /* | 280 | /* |
| 271 | * initstate: | 281 | * initstate: |
| 272 | * | 282 | * |
| @@ -429,3 +439,8 @@ random(void) | |||
| 429 | UNLOCK(); | 439 | UNLOCK(); |
| 430 | return r; | 440 | return r; |
| 431 | } | 441 | } |
| 442 | |||
| 443 | #if defined(APIWARN) | ||
| 444 | __warn_references(random, | ||
| 445 | "warning: random() isn't random; consider using arc4random()"); | ||
| 446 | #endif | ||
