Skip site navigation (1)Skip section navigation (2)
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

[-- Attachment #1 --]
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 = 0;
> > -	fd = _open("/dev/random", O_RDONLY | O_CLOEXEC, 0);
> > -	if (fd >= 0) {
> > -		if (_read(fd, (void *) &next, sizeof(next)) == sizeof(next))
> > -			done = 1;
> > -		_close(fd);
> > -	}
> > -
> > -	if (!done) {
> > -		struct timeval tv;
> > -
> > -		gettimeofday(&tv, NULL);
> > -		srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec);
> > -	}
> 
> _open() and _read() are unlikely to fail, [...]

They are very likely to fail when the process is sandboxed.

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iEYEARECAAYFAlFcOZ0ACgkQForvXbEpPzRj+gCgpya1sbMIKDsE90d5qAeoZM3i
x90AoJLTeA78UOEL6v7OIPyKkZM1iN9W
=/5CI
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130403141557.GB1349>