random_r.3: 'buf.state' must be initialized to NULL before calling initstate_r()

See https://bugzilla.kernel.org/show_bug.cgi?id=192801.

See also the glibc source file string/strfry.c, which shows
an example of this initialization:

  if (!init)
    {
      static char state[32];
      rdata.state = NULL;
      __initstate_r (time ((time_t *) NULL) ^ getpid (),
                     state, sizeof (state), &rdata);
      init = 1;
    }

Reported-by: Jan Ziak <0xe2.0x9a.0x9b@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-01-25 08:39:18 +13:00
parent 48ac01a782
commit 91e37268d6
1 changed files with 3 additions and 0 deletions

View File

@ -94,6 +94,9 @@ function is like
except that it initializes the state in the object pointed to by
.IR buf ,
rather than initializing the global state variable.
Before calling this function, the
.IR buf.state
field must be initialized to NULL.
The
.BR setstate_r ()