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
pgptvCBU3OlAK.pgp
Description: PGP signature