[Pkg-shadow-devel] Bug#677275: passwd: RAND_MAX is for rand() only, and on some systems random() can exceed RAND_MAX

Alexander Gattin xrgtn at yandex.ru
Wed Jun 13 11:16:56 UTC 2012


The GNU/Linux random(3) manpage says explicitly:
> The random() function returns a value between
> 0 and RAND_MAX

The same is said in GNU libc docs (info libc "BSD
Random"):
> This section describes a set of random number
> generation functions that are derived from BSD.
> There is no advantage to using these functions
> with the GNU C library; we support them for BSD
> compatibility only.
...
> The value returned ranges from `0' to
> `RAND_MAX'.

This doesn't contradict HP-UX, Tru64, Solaris, BSD
and SUS/XPG, because RAND_MAX on GNU/Linux is
defined as 2^31-1:
> /usr/include/stdlib.h:#define   RAND_MAX        2147483647

Probably, we should use RAND_MAX on GNU (both
Linux and Hurd), and 0x7fffffff on all other
systems?

-- 
With best regards,
xrgtn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-shadow-devel/attachments/20120613/c8ef92be/attachment.pgp>


More information about the Pkg-shadow-devel mailing list