Browse Source

improve warnings from rand_r(), rand(), and random()

It may take a few iterations to get the tone right.
previously discussed with millert
OPENBSD_5_7
deraadt 9 years ago
parent
commit
a03b475103
2 changed files with 8 additions and 3 deletions
  1. +2
    -2
      src/lib/libc/stdlib/rand.c
  2. +6
    -1
      src/lib/libc/stdlib/random.c

+ 2
- 2
src/lib/libc/stdlib/rand.c View File

@ -42,7 +42,7 @@ rand_r(u_int *seed)
#if defined(APIWARN)
__warn_references(rand_r,
"warning: rand_r() isn't random; consider using arc4random()");
"warning: rand_r() is not random, it is deterministic.");
#endif
int
@ -55,7 +55,7 @@ rand(void)
#if defined(APIWARN)
__warn_references(rand,
"warning: rand() isn't random; consider using arc4random()");
"warning: rand() may return determinstic values, is that what you want?");
#endif
void


+ 6
- 1
src/lib/libc/stdlib/random.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: random.c,v 1.25 2014/12/08 21:45:20 deraadt Exp $ */
/* $OpenBSD: random.c,v 1.26 2014/12/09 08:00:53 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
@ -415,3 +415,8 @@ random(void)
UNLOCK();
return r;
}
#if defined(APIWARN)
__warn_references(rand,
"warning: random() may return determinstic values, is that what you want?");
#endif

Loading…
Cancel
Save