summaryrefslogtreecommitdiff
path: root/opacket.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-28 21:15:47 +0000
committerDamien Miller <djm@mindrot.org>2015-01-29 09:08:07 +1100
commitfae7bbe544cba7a9e5e4ab47ff6faa3d978646eb (patch)
treea27a07031b600a1925a128bc0f5258a4b3ab2e8c /opacket.c
parent1a3d14f6b44a494037c7deab485abe6496bf2c60 (diff)
downloadopenssh-git-fae7bbe544cba7a9e5e4ab47ff6faa3d978646eb.tar.gz
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.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/opacket.c b/opacket.c
index 63b419d5..a137b5a8 100644
--- a/opacket.c
+++ b/opacket.c
@@ -255,8 +255,20 @@ packet_read_seqnr(u_int32_t *seqnr)
u_char type;
int r;
- if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)))
- fatal("%s: %s", __func__, ssh_err(r));
+ if ((r = ssh_packet_read_seqnr(active_state, &type, seqnr)) != 0) {
+ switch (r) {
+ case SSH_ERR_CONN_CLOSED:
+ logit("Connection closed by %.200s",
+ ssh_remote_ipaddr(active_state));
+ cleanup_exit(255);
+ case SSH_ERR_CONN_TIMEOUT:
+ logit("Connection to %.200s timed out while "
+ "waiting to read", ssh_remote_ipaddr(active_state));
+ cleanup_exit(255);
+ default:
+ fatal("%s: %s", __func__, ssh_err(r));
+ }
+ }
return type;
}
@@ -277,3 +289,12 @@ packet_close(void)
ssh_packet_close(active_state);
active_state = NULL;
}
+
+void
+packet_process_incoming(const char *buf, u_int len)
+{
+ int r;
+
+ if ((r = ssh_packet_process_incoming(active_state, buf, len)) != 0)
+ fatal("%s: %s", __func__, ssh_err(r));
+}