summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2001-03-19 10:52:52 +0000
committerDamien Miller <djm@cvs.openbsd.org>2001-03-19 10:52:52 +0000
commit0ec33e3549d0d41d4d33b405774ce307e1291cad (patch)
tree2535f54bd850ae9cf044dca0229cffeac2098fae /usr.bin
parent5faf4fc4b3ef0cf362779a35721878418282884c (diff)
Report ssh connection closing correctly; ok deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sftp-client.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c
index e40a73875d3..b869976c30e 100644
--- a/usr.bin/ssh/sftp-client.c
+++ b/usr.bin/ssh/sftp-client.c
@@ -29,7 +29,7 @@
/* XXX: copy between two remote sites */
#include "includes.h"
-RCSID("$OpenBSD: sftp-client.c,v 1.14 2001/03/16 08:16:17 djm Exp $");
+RCSID("$OpenBSD: sftp-client.c,v 1.15 2001/03/19 10:52:51 djm Exp $");
#include "ssh.h"
#include "buffer.h"
@@ -77,7 +77,9 @@ get_msg(int fd, Buffer *m)
unsigned char buf[4096];
len = atomicio(read, fd, buf, 4);
- if (len != 4)
+ if (len == 0)
+ fatal("Connection closed");
+ else if (len == -1)
fatal("Couldn't read packet: %s", strerror(errno));
msg_len = GET_32BIT(buf);
@@ -86,7 +88,9 @@ get_msg(int fd, Buffer *m)
while (msg_len) {
len = atomicio(read, fd, buf, MIN(msg_len, sizeof(buf)));
- if (len <= 0)
+ if (len == 0)
+ fatal("Connection closed");
+ else if (len == -1)
fatal("Couldn't read packet: %s", strerror(errno));
msg_len -= len;