View | Details | Raw Unified | Return to bug 1363 | Differences between
and this patch

Collapse All | Expand All

(-)packet.c.orig (-4 / +35 lines)
Lines 122-127 static int server_side = 0; Link Here
122
/* Set to true if we are authenticated. */
122
/* Set to true if we are authenticated. */
123
static int after_authentication = 0;
123
static int after_authentication = 0;
124
124
125
/* Set to the maximum time that we will wait to send or receive a packet */
126
static struct timeval packet_wait_tv;
127
static struct timeval *packet_wait_tvp = NULL;
128
125
/* Session key information for Encryption and MAC */
129
/* Session key information for Encryption and MAC */
126
Newkeys *newkeys[MODE_MAX];
130
Newkeys *newkeys[MODE_MAX];
127
static struct packet_state {
131
static struct packet_state {
Lines 175-180 packet_set_connection(int fd_in, int fd_ Link Here
175
	}
179
	}
176
}
180
}
177
181
182
void
183
packet_set_timeout(int timeout, int count)
184
{
185
	if (timeout == 0 || count == 0) {
186
		packet_wait_tvp = NULL;
187
		return;
188
	}
189
	if (LONG_MAX / count < timeout)
190
		packet_wait_tv.tv_sec = LONG_MAX;
191
	else
192
		packet_wait_tv.tv_sec = timeout * count;
193
	packet_wait_tv.tv_usec = 0;
194
	packet_wait_tvp = &packet_wait_tv;
195
}
196
178
/* Returns 1 if remote host is connected via socket, 0 if not. */
197
/* Returns 1 if remote host is connected via socket, 0 if not. */
179
198
180
int
199
int
Lines 863-869 packet_send(void) Link Here
863
int
882
int
864
packet_read_seqnr(u_int32_t *seqnr_p)
883
packet_read_seqnr(u_int32_t *seqnr_p)
865
{
884
{
866
	int type, len;
885
	int type, len, ret;
867
	fd_set *setp;
886
	fd_set *setp;
868
	char buf[8192];
887
	char buf[8192];
869
	DBG(debug("packet_read()"));
888
	DBG(debug("packet_read()"));
Lines 898-907 packet_read_seqnr(u_int32_t *seqnr_p) Link Here
898
		FD_SET(connection_in, setp);
917
		FD_SET(connection_in, setp);
899
918
900
		/* Wait for some data to arrive. */
919
		/* Wait for some data to arrive. */
901
		while (select(connection_in + 1, setp, NULL, NULL, NULL) == -1 &&
920
		while ((ret = select(connection_in + 1, setp, NULL, NULL,
921
		    packet_wait_tvp)) == -1 &&
902
		    (errno == EAGAIN || errno == EINTR))
922
		    (errno == EAGAIN || errno == EINTR))
903
			;
923
			;
904
924
		if (ret == 0) {
925
			logit("Connection to %.200s timed out while waiting to read",
926
			    get_remote_ipaddr());
927
			cleanup_exit(255);
928
		}
905
		/* Read data from the socket. */
929
		/* Read data from the socket. */
906
		len = read(connection_in, buf, sizeof(buf));
930
		len = read(connection_in, buf, sizeof(buf));
907
		if (len == 0) {
931
		if (len == 0) {
Lines 1411-1416 void Link Here
1411
packet_write_wait(void)
1435
packet_write_wait(void)
1412
{
1436
{
1413
	fd_set *setp;
1437
	fd_set *setp;
1438
	int ret;
1414
1439
1415
	setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) *
1440
	setp = (fd_set *)xmalloc(howmany(connection_out + 1, NFDBITS) *
1416
	    sizeof(fd_mask));
1441
	    sizeof(fd_mask));
Lines 1419-1427 packet_write_wait(void) Link Here
1419
		memset(setp, 0, howmany(connection_out + 1, NFDBITS) *
1444
		memset(setp, 0, howmany(connection_out + 1, NFDBITS) *
1420
		    sizeof(fd_mask));
1445
		    sizeof(fd_mask));
1421
		FD_SET(connection_out, setp);
1446
		FD_SET(connection_out, setp);
1422
		while (select(connection_out + 1, NULL, setp, NULL, NULL) == -1 &&
1447
		while ((ret = select(connection_out + 1, NULL, setp, NULL,
1448
		    packet_wait_tvp)) == -1 &&
1423
		    (errno == EAGAIN || errno == EINTR))
1449
		    (errno == EAGAIN || errno == EINTR))
1424
			;
1450
			;
1451
		if (ret == 0) {
1452
			logit("Connection to %.200s timed out while waiting to write",
1453
			    get_remote_ipaddr());
1454
			cleanup_exit(255);
1455
		}
1425
		packet_write_poll();
1456
		packet_write_poll();
1426
	}
1457
	}
1427
	xfree(setp);
1458
	xfree(setp);
(-)packet.h.orig (+1 lines)
Lines 19-24 Link Here
19
#include <openssl/bn.h>
19
#include <openssl/bn.h>
20
20
21
void     packet_set_connection(int, int);
21
void     packet_set_connection(int, int);
22
void     packet_set_timeout(int, int);
22
void     packet_set_nonblocking(void);
23
void     packet_set_nonblocking(void);
23
int      packet_get_connection_in(void);
24
int      packet_get_connection_in(void);
24
int      packet_get_connection_out(void);
25
int      packet_get_connection_out(void);
(-)sshconnect.c.orig (+4 lines)
Lines 139-144 ssh_proxy_connect(const char *host, u_sh Link Here
139
139
140
	/* Set the connection file descriptors. */
140
	/* Set the connection file descriptors. */
141
	packet_set_connection(pout[0], pin[1]);
141
	packet_set_connection(pout[0], pin[1]);
142
	packet_set_timeout(options.server_alive_interval,
143
	    options.server_alive_count_max);
142
144
143
	/* Indicate OK return */
145
	/* Indicate OK return */
144
	return 0;
146
	return 0;
Lines 381-386 ssh_connect(const char *host, struct soc Link Here
381
383
382
	/* Set the connection. */
384
	/* Set the connection. */
383
	packet_set_connection(sock, sock);
385
	packet_set_connection(sock, sock);
386
	packet_set_timeout(options.server_alive_interval,
387
	    options.server_alive_count_max);
384
388
385
	return 0;
389
	return 0;
386
}
390
}
(-)sshd.c.orig (+2 lines)
Lines 1643-1648 main(int ac, char **av) Link Here
1643
	 * not have a key.
1643
	 * not have a key.
1644
	 */
1644
	 */
1645
	packet_set_connection(sock_in, sock_out);
1645
	packet_set_connection(sock_in, sock_out);
1646
	packet_set_timeout(options.client_alive_interval,
1647
	    options.client_alive_count_max);
1646
	packet_set_server();
1648
	packet_set_server();
1647
1649
1648
	/* Set SO_KEEPALIVE if requested. */
1650
	/* Set SO_KEEPALIVE if requested. */

Return to bug 1363