diff --git a/TODO b/TODO index 7acc8c03a476d6e88ff03ba60144bd9f1cd63106..cfd045b87e84b0c885b98f32a7b372e4f5cf8396 100644 --- a/TODO +++ b/TODO @@ -4,9 +4,6 @@ Things which might need doing: - Make options.h generated from configure perhaps? -- some sort of warning when blocking on random? (could be difficult, - investigate alarm() perhaps) - - Improved queueing of unauthed connections - handle /etc/environment in AIX diff --git a/cli-tcpfwd.c b/cli-tcpfwd.c index aa5b72019bd44abf32ffa5c1954c80c59f4fa54a..300a2fabeff1107fdcd4917bd04ee48cf1f52e0f 100644 --- a/cli-tcpfwd.c +++ b/cli-tcpfwd.c @@ -94,7 +94,7 @@ static int cli_localtcp(unsigned int listenport, const char* remoteaddr, TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr, remoteport)); - tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener*)); + tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener)); tcpinfo->sendaddr = m_strdup(remoteaddr); tcpinfo->sendport = remoteport; tcpinfo->listenport = listenport; diff --git a/random.c b/random.c index 2b2777ae2cd0a81314fc3bd9fd8820fbb5e6a07d..8012148bc04932afefd687a27bed4dcf68dacaba 100644 --- a/random.c +++ b/random.c @@ -51,6 +51,7 @@ static void readrand(unsigned char* buf, unsigned int buflen); static void readrand(unsigned char* buf, unsigned int buflen) { + static int already_blocked = 0; int readfd; unsigned int readpos; int readlen; @@ -93,6 +94,24 @@ static void readrand(unsigned char* buf, unsigned int buflen) { /* 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) {