can block forever) for our seed. This fixes a problem with our new Linux
build slave, which is running Linux 2.6 as a VM guest, and which was
timing out waiting for entropy.
Add a comment about using CryptGenRandom on Windows.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31456
f5534014-38df-0310-8fa8-
9805f1628bb7
+#define RANDOM_DEV "/dev/urandom"
+
- * Assume it's at least worth trying /dev/random on UN*X.
+ * Assume it's at least worth trying /dev/urandom on UN*X.
* If it doesn't exist, fall back on time().
*
* If it doesn't exist, fall back on time().
*
- * XXX - does Windows have a system source of entropy?
+ * XXX - Use CryptGenRandom on Windows?
- fd = open("/dev/random", O_RDONLY);
+ fd = open(RANDOM_DEV, O_RDONLY);
if (fd == -1) {
if (errno != ENOENT) {
fprintf(stderr,
if (fd == -1) {
if (errno != ENOENT) {
fprintf(stderr,
- "randpkt: Could not open /dev/random for reading: %s\n",
+ "randpkt: Could not open " RANDOM_DEV " for reading: %s\n",
strerror(errno));
exit(2);
}
strerror(errno));
exit(2);
}
ret = read(fd, &randomness, sizeof randomness);
if (ret == -1) {
fprintf(stderr,
ret = read(fd, &randomness, sizeof randomness);
if (ret == -1) {
fprintf(stderr,
- "randpkt: Could not read from /dev/random: %s\n",
+ "randpkt: Could not read from " RANDOM_DEV ": %s\n",
strerror(errno));
exit(2);
}
if ((size_t)ret != sizeof randomness) {
fprintf(stderr,
strerror(errno));
exit(2);
}
if ((size_t)ret != sizeof randomness) {
fprintf(stderr,
- "randpkt: Tried to read %lu bytes from /dev/random, got %ld\n",
+ "randpkt: Tried to read %lu bytes from " RANDOM_DEV ", got %ld\n",
(unsigned long)sizeof randomness, (long)ret);
exit(2);
}
(unsigned long)sizeof randomness, (long)ret);
exit(2);
}