diff options
author | djm@openbsd.org <djm@openbsd.org> | 2015-01-28 21:15:47 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-01-29 09:08:07 +1100 |
commit | fae7bbe544cba7a9e5e4ab47ff6faa3d978646eb (patch) | |
tree | a27a07031b600a1925a128bc0f5258a4b3ab2e8c /opacket.c | |
parent | 1a3d14f6b44a494037c7deab485abe6496bf2c60 (diff) |
upstream commit
avoid fatal() calls in packet code makes ssh-keyscan more
reliable against server failures ok dtucker@ markus@
Diffstat (limited to 'opacket.c')
-rw-r--r-- | opacket.c | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -255,8 +255,20 @@ packet_read_seqnr(u_int32_t *seqnr) | |||
255 | u_char type; | 255 | u_char type; |
256 | int r; | 256 | int r; |
257 | 257 | ||
258 | if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr))) | 258 | if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) { |
259 | fatal("%s: %s", __func__, ssh_err(r)); | 259 | switch (r) { |
260 | case SSH_ERR_CONN_CLOSED: | ||
261 | logit("Connection closed by %.200s", | ||
262 | ssh_remote_ipaddr(active_state)); | ||
263 | cleanup_exit(255); | ||
264 | case SSH_ERR_CONN_TIMEOUT: | ||
265 | logit("Connection to %.200s timed out while " | ||
266 | "waiting to read", ssh_remote_ipaddr(active_state)); | ||
267 | cleanup_exit(255); | ||
268 | default: | ||
269 | fatal("%s: %s", __func__, ssh_err(r)); | ||
270 | } | ||
271 | } | ||
260 | return type; | 272 | return type; |
261 | } | 273 | } |
262 | 274 | ||
@@ -277,3 +289,12 @@ packet_close(void) | |||
277 | ssh_packet_close(active_state); | 289 | ssh_packet_close(active_state); |
278 | active_state = NULL; | 290 | active_state = NULL; |
279 | } | 291 | } |
292 | |||
293 | void | ||
294 | packet_process_incoming(const char *buf, u_int len) | ||
295 | { | ||
296 | int r; | ||
297 | |||
298 | if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0) | ||
299 | fatal("%s: %s", __func__, ssh_err(r)); | ||
300 | } | ||