Date: Wed, 3 Apr 2013 16:15:57 +0200 From: Pawel Jakub Dawidek <pjd@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Xin LI <delphij@FreeBSD.org> Subject: Re: svn commit: r249035 - head/lib/libc/stdlib Message-ID: <20130403141557.GB1349@garage.freebsd.pl> In-Reply-To: <20130403165736.F819@besplex.bde.org> References: <201304022341.r32NfL8L096954@svn.freebsd.org> <20130403165736.F819@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--uQr8t48UFsdbeI+V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 03, 2013 at 06:04:37PM +1100, Bruce Evans wrote: > On Tue, 2 Apr 2013, Xin LI wrote: > > void > > sranddev() > > { > > - int fd, done; > > + int mib[2]; > > + size_t len; > > > > - done =3D 0; > > - fd =3D _open("/dev/random", O_RDONLY | O_CLOEXEC, 0); > > - if (fd >=3D 0) { > > - if (_read(fd, (void *) &next, sizeof(next)) =3D=3D sizeof(next)) > > - done =3D 1; > > - _close(fd); > > - } > > - > > - if (!done) { > > - struct timeval tv; > > - > > - gettimeofday(&tv, NULL); > > - srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec); > > - } >=20 > _open() and _read() are unlikely to fail, [...] They are very likely to fail when the process is sandboxed. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --uQr8t48UFsdbeI+V Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlFcOZ0ACgkQForvXbEpPzRj+gCgpya1sbMIKDsE90d5qAeoZM3i x90AoJLTeA78UOEL6v7OIPyKkZM1iN9W =/5CI -----END PGP SIGNATURE----- --uQr8t48UFsdbeI+V--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130403141557.GB1349>