Random

PHOTO EMBED

Mon Aug 30 2021 00:18:42 GMT+0000 (Coordinated Universal Time)

Saved by @luisjdominguezp #c

int fd = open("/dev/urandom", O_RDONLY);
if (fd == -1)
	goto nodevurandom
if (fstat(fd, &st) == -1 || !S_ISCHR(st.st_mode)) {
	close(fd);
	goto nodevrandom;
}
if (ioctl(fd, RNDGETENTCNT, &cnt) == -1) {
	close(fd);
	goto nodevrandom;
}
ssize_t ret = read(fd, (char *)buf + i, wanted);
if (ret == -1) {
	if (errno == EAGAIN || errno == EINTR)
		continue;
		close(fd);
		goto nodevrandom;
}
close(fd);
if (gotdata(buf, len) == 0) {
	errno = save_errno;
	return 0;
}
nodevrandom:
	errno = EIO;
	return -1;
content_copyCOPY