merge of 6b56bdff53b47ae7366d93b496ce353d9e3753dc

and b68c53583ba80ad14fd0ba70ff26ea3dbd8e8823

--HG--
extra : convert_revision : 0a69485db882269664dcd5ec88e66b8ea9570855
This commit is contained in:
Matt Johnston 2005-05-05 04:00:10 +00:00
commit 68445e1e34
3 changed files with 20 additions and 4 deletions

3
TODO
View File

@ -4,9 +4,6 @@ Things which might need doing:
- Make options.h generated from configure perhaps? - 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 - Improved queueing of unauthed connections
- handle /etc/environment in AIX - handle /etc/environment in AIX

View File

@ -94,7 +94,7 @@ static int cli_localtcp(unsigned int listenport, const char* remoteaddr,
TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr, TRACE(("enter cli_localtcp: %d %s %d", listenport, remoteaddr,
remoteport)); remoteport));
tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener*)); tcpinfo = (struct TCPListener*)m_malloc(sizeof(struct TCPListener));
tcpinfo->sendaddr = m_strdup(remoteaddr); tcpinfo->sendaddr = m_strdup(remoteaddr);
tcpinfo->sendport = remoteport; tcpinfo->sendport = remoteport;
tcpinfo->listenport = listenport; tcpinfo->listenport = listenport;

View File

@ -51,6 +51,7 @@ static void readrand(unsigned char* buf, unsigned int buflen);
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; int readfd;
unsigned int readpos; unsigned int readpos;
int readlen; int readlen;
@ -93,6 +94,24 @@ static void readrand(unsigned char* buf, unsigned int buflen) {
/* read the actual random data */ /* read the actual random data */
readpos = 0; readpos = 0;
do { 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); readlen = read(readfd, &buf[readpos], buflen - readpos);
if (readlen <= 0) { if (readlen <= 0) {
if (readlen < 0 && errno == EINTR) { if (readlen < 0 && errno == EINTR) {