The unified diff between revisions [9a4e042f..] and [e08c6d89..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "random.c"
# from [f5ffe4513c9c40cb4432ea6d201fd3f3b4e14946]
# to [7a0da732314a4748499377bdd22686ccb772b3fc]
#
============================================================
--- random.c f5ffe4513c9c40cb4432ea6d201fd3f3b4e14946
+++ random.c 7a0da732314a4748499377bdd22686ccb772b3fc
@@ -93,36 +93,7 @@ static void readrand(unsigned char* buf,
#endif
/* read the actual random data */
- readpos = 0;
- do {
- if (!already_blocked)
- {
- int ret;
- struct timeval timeout;
- fd_set read_fds;
- timeout.tv_sec = 2; /* two seconds should be enough */
- timeout.tv_usec = 0;
-
- FD_ZERO(&read_fds);
- FD_SET(readfd, &read_fds);
- ret = select(readfd + 1, &read_fds, NULL, NULL, &timeout);
- if (ret == 0)
- {
- dropbear_log(LOG_INFO, "Warning: Reading the random source seems to have blocked.\nIf you experience problems, you probably need to find a better entropy source.");
- already_blocked = 1;
- }
- }
- readlen = read(readfd, &buf[readpos], buflen - readpos);
- if (readlen <= 0) {
- if (readlen < 0 && errno == EINTR) {
- continue;
- }
- dropbear_exit("error reading random source");
- }
- readpos += readlen;
- } while (readpos < buflen);
-
close (readfd);
}
@@ -157,21 +128,14 @@ void reseedrandom() {
* the random pools for fork()ed processes. */
void reseedrandom() {
- pid_t pid;
hash_state hs;
- struct timeval tv;
if (!donerandinit) {
dropbear_exit("seedrandom not done");
}
- pid = getpid();
- gettimeofday(&tv, NULL);
-
sha1_init(&hs);
sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
- sha1_process(&hs, (void*)&pid, sizeof(pid));
- sha1_process(&hs, (void*)&tv, sizeof(tv));
sha1_done(&hs, hashpool);
}