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

Collapse All | Expand All

(-)dispatch.c (-2 / +14 lines)
Lines 135-140 ssh_dispatch_run_fatal(struct ssh *ssh, Link Here
135
{
135
{
136
	int r;
136
	int r;
137
137
138
	if ((r = ssh_dispatch_run(ssh, mode, done, ctxt)) != 0)
138
	if ((r = ssh_dispatch_run(ssh, mode, done, ctxt)) != 0) {
139
		fatal("%s: %s", __func__, ssh_err(r));
139
		switch (r) {
140
		case SSH_ERR_CONN_CLOSED:
141
			logit("Connection closed by %.200s",
142
			    ssh_remote_ipaddr(ssh));
143
			cleanup_exit(255);
144
		case SSH_ERR_CONN_TIMEOUT:
145
			logit("Connection to %.200s timed out while "
146
			    "waiting to read", ssh_remote_ipaddr(ssh));
147
			cleanup_exit(255);
148
		default:
149
			fatal("%s: %s", __func__, ssh_err(r));
150
		}
151
	}
140
}
152
}
(-)opacket.c (-2 / +23 lines)
Lines 253-260 packet_read_seqnr(u_int32_t *seqnr) Link Here
253
	u_char type;
253
	u_char type;
254
	int r;
254
	int r;
255
255
256
	if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)))
256
	if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) {
257
		fatal("%s: %s", __func__, ssh_err(r));
257
		switch (r) {
258
		case SSH_ERR_CONN_CLOSED:
259
			logit("Connection closed by %.200s",
260
			    ssh_remote_ipaddr(active_state));
261
			cleanup_exit(255);
262
		case SSH_ERR_CONN_TIMEOUT:
263
			logit("Connection to %.200s timed out while "
264
			    "waiting to read", ssh_remote_ipaddr(active_state));
265
			cleanup_exit(255);
266
		default:
267
			fatal("%s: %s", __func__, ssh_err(r));
268
		}
269
	}
258
	return type;
270
	return type;
259
}
271
}
260
272
Lines 274-277 packet_close(void) Link Here
274
{
286
{
275
	ssh_packet_close(active_state);
287
	ssh_packet_close(active_state);
276
	active_state = NULL;
288
	active_state = NULL;
289
}
290
291
void
292
packet_process_incoming(const char *buf, u_int len)
293
{
294
	int r;
295
296
	if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0)
297
		fatal("%s: %s", __func__, ssh_err(r));
277
}
298
}
(-)opacket.h (-2 / +1 lines)
Lines 44-49 void packet_restore_state(void); Link Here
44
void     packet_set_connection(int, int);
44
void     packet_set_connection(int, int);
45
int	 packet_read_seqnr(u_int32_t *);
45
int	 packet_read_seqnr(u_int32_t *);
46
int	 packet_read_poll_seqnr(u_int32_t *);
46
int	 packet_read_poll_seqnr(u_int32_t *);
47
void	 packet_process_incoming(const char *buf, u_int len);
47
#define packet_set_timeout(timeout, count) \
48
#define packet_set_timeout(timeout, count) \
48
	ssh_packet_set_timeout(active_state, (timeout), (count))
49
	ssh_packet_set_timeout(active_state, (timeout), (count))
49
#define packet_connection_is_on_socket() \
50
#define packet_connection_is_on_socket() \
Lines 86-93 int packet_read_poll_seqnr(u_int32_t *) Link Here
86
	ssh_packet_read(active_state)
87
	ssh_packet_read(active_state)
87
#define packet_read_expect(expected_type) \
88
#define packet_read_expect(expected_type) \
88
	ssh_packet_read_expect(active_state, (expected_type))
89
	ssh_packet_read_expect(active_state, (expected_type))
89
#define packet_process_incoming(buf, len) \
90
	ssh_packet_process_incoming(active_state, (buf), (len))
91
#define packet_get_int64() \
90
#define packet_get_int64() \
92
	ssh_packet_get_int64(active_state)
91
	ssh_packet_get_int64(active_state)
93
#define packet_get_bignum(value) \
92
#define packet_get_bignum(value) \
(-)packet.c (-17 / +14 lines)
Lines 1302-1327 ssh_packet_read_seqnr(struct ssh *ssh, u Link Here
1302
				break;
1302
				break;
1303
			}
1303
			}
1304
		}
1304
		}
1305
		if (r == 0) {
1305
		if (r == 0)
1306
			logit("Connection to %.200s timed out while "
1306
			return SSH_ERR_CONN_TIMEOUT;
1307
			    "waiting to read", ssh_remote_ipaddr(ssh));
1308
			cleanup_exit(255);
1309
		}
1310
		/* Read data from the socket. */
1307
		/* Read data from the socket. */
1311
		do {
1308
		do {
1312
			cont = 0;
1309
			cont = 0;
1313
			len = roaming_read(state->connection_in, buf,
1310
			len = roaming_read(state->connection_in, buf,
1314
			    sizeof(buf), &cont);
1311
			    sizeof(buf), &cont);
1315
		} while (len == 0 && cont);
1312
		} while (len == 0 && cont);
1316
		if (len == 0) {
1313
		if (len == 0)
1317
			logit("Connection closed by %.200s",
1314
			return SSH_ERR_CONN_CLOSED;
1318
			    ssh_remote_ipaddr(ssh));
1319
			cleanup_exit(255);
1320
		}
1321
		if (len < 0)
1315
		if (len < 0)
1322
			fatal("Read from socket failed: %.100s", strerror(errno));
1316
			return SSH_ERR_SYSTEM_ERROR;
1317
1323
		/* Append it to the buffer. */
1318
		/* Append it to the buffer. */
1324
		ssh_packet_process_incoming(ssh, buf, len);
1319
		if ((r = ssh_packet_process_incoming(ssh, buf, len)) != 0)
1320
			return r;
1325
	}
1321
	}
1326
	free(setp);
1322
	free(setp);
1327
	return r;
1323
	return r;
Lines 1775-1781 ssh_packet_read_poll_seqnr(struct ssh *s Link Here
1775
 * together with packet_read_poll.
1771
 * together with packet_read_poll.
1776
 */
1772
 */
1777
1773
1778
void
1774
int
1779
ssh_packet_process_incoming(struct ssh *ssh, const char *buf, u_int len)
1775
ssh_packet_process_incoming(struct ssh *ssh, const char *buf, u_int len)
1780
{
1776
{
1781
	struct session_state *state = ssh->state;
1777
	struct session_state *state = ssh->state;
Lines 1785-1798 ssh_packet_process_incoming(struct ssh * Link Here
1785
		state->keep_alive_timeouts = 0; /* ?? */
1781
		state->keep_alive_timeouts = 0; /* ?? */
1786
		if (len >= state->packet_discard) {
1782
		if (len >= state->packet_discard) {
1787
			if ((r = ssh_packet_stop_discard(ssh)) != 0)
1783
			if ((r = ssh_packet_stop_discard(ssh)) != 0)
1788
				fatal("%s: %s", __func__, ssh_err(r));
1784
				return r;
1789
			cleanup_exit(255);
1790
		}
1785
		}
1791
		state->packet_discard -= len;
1786
		state->packet_discard -= len;
1792
		return;
1787
		return 0;
1793
	}
1788
	}
1794
	if ((r = sshbuf_put(ssh->state->input, buf, len)) != 0)
1789
	if ((r = sshbuf_put(ssh->state->input, buf, len)) != 0)
1795
		fatal("%s: %s", __func__, ssh_err(r));
1790
		return r;
1791
1792
	return 0;
1796
}
1793
}
1797
1794
1798
int
1795
int
(-)packet.h (-1 / +1 lines)
Lines 90-96 void ssh_packet_read_expect(struct s Link Here
90
int      ssh_packet_read_poll(struct ssh *);
90
int      ssh_packet_read_poll(struct ssh *);
91
int ssh_packet_read_poll1(struct ssh *, u_char *);
91
int ssh_packet_read_poll1(struct ssh *, u_char *);
92
int ssh_packet_read_poll2(struct ssh *, u_char *, u_int32_t *seqnr_p);
92
int ssh_packet_read_poll2(struct ssh *, u_char *, u_int32_t *seqnr_p);
93
void     ssh_packet_process_incoming(struct ssh *, const char *buf, u_int len);
93
int	 ssh_packet_process_incoming(struct ssh *, const char *buf, u_int len);
94
int      ssh_packet_read_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
94
int      ssh_packet_read_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
95
int      ssh_packet_read_poll_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
95
int      ssh_packet_read_poll_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
96
96
(-)ssh-keyscan.c (-2 / +4 lines)
Lines 301-308 tcpconnect(char *host) Link Here
301
	memset(&hints, 0, sizeof(hints));
301
	memset(&hints, 0, sizeof(hints));
302
	hints.ai_family = IPv4or6;
302
	hints.ai_family = IPv4or6;
303
	hints.ai_socktype = SOCK_STREAM;
303
	hints.ai_socktype = SOCK_STREAM;
304
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
304
	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) {
305
		fatal("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr));
305
		error("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr));
306
		return -1;
307
	}
306
	for (ai = aitop; ai; ai = ai->ai_next) {
308
	for (ai = aitop; ai; ai = ai->ai_next) {
307
		s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
309
		s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
308
		if (s < 0) {
310
		if (s < 0) {
(-)ssherr.c (+4 lines)
Lines 125-130 ssh_err(int n) Link Here
125
		return "KRL file has invalid magic number";
125
		return "KRL file has invalid magic number";
126
	case SSH_ERR_KEY_REVOKED:
126
	case SSH_ERR_KEY_REVOKED:
127
		return "Key is revoked";
127
		return "Key is revoked";
128
	case SSH_ERR_CONN_CLOSED:
129
		return "Connection closed";
130
	case SSH_ERR_CONN_TIMEOUT:
131
		return "Connection timed out";
128
	default:
132
	default:
129
		return "unknown error";
133
		return "unknown error";
130
	}
134
	}
(-)ssherr.h (+2 lines)
Lines 73-78 Link Here
73
#define SSH_ERR_BUFFER_READ_ONLY		-49
73
#define SSH_ERR_BUFFER_READ_ONLY		-49
74
#define SSH_ERR_KRL_BAD_MAGIC			-50
74
#define SSH_ERR_KRL_BAD_MAGIC			-50
75
#define SSH_ERR_KEY_REVOKED			-51
75
#define SSH_ERR_KEY_REVOKED			-51
76
#define SSH_ERR_CONN_CLOSED			-52
77
#define SSH_ERR_CONN_TIMEOUT			-53
76
78
77
/* Translate a numeric error code to a human-readable error string */
79
/* Translate a numeric error code to a human-readable error string */
78
const char *ssh_err(int n);
80
const char *ssh_err(int n);

Return to bug 1213