aboutsummaryrefslogtreecommitdiff
path: root/src/sftp.c
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2018-12-03 17:25:22 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-12-07 17:43:08 +0100
commitd78a29eb792fd09c836dd5f5db7f29c1c449ec2a (patch)
treeafa0fa09dab98417eaea909ba1bc8b2c3f93980d /src/sftp.c
parent58113d489eecfeb266b82de7bb25d4a0526b9606 (diff)
downloadlibssh-d78a29eb792fd09c836dd5f5db7f29c1c449ec2a.tar.gz
libssh-d78a29eb792fd09c836dd5f5db7f29c1c449ec2a.tar.xz
libssh-d78a29eb792fd09c836dd5f5db7f29c1c449ec2a.zip
sftp: Set error when EOF is received in sftp_packet_read()
When reading a sftp packet and an EOF is received before all requested bytes are read, set the session and sftp error codes. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/sftp.c')
-rw-r--r--src/sftp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sftp.c b/src/sftp.c
index b4ddedcd..c4cd0e16 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -396,6 +396,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
} else if (s == 0) {
is_eof = ssh_channel_is_eof(sftp->channel);
if (is_eof) {
+ ssh_set_error(sftp->session,
+ SSH_FATAL,
+ "Received EOF while reading sftp packet size");
+ sftp_set_error(sftp, SSH_FX_EOF);
goto error;
}
} else {
@@ -416,6 +420,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
} else if (nread == 0) {
is_eof = ssh_channel_is_eof(sftp->channel);
if (is_eof) {
+ ssh_set_error(sftp->session,
+ SSH_FATAL,
+ "Received EOF while reading sftp packet type");
+ sftp_set_error(sftp, SSH_FX_EOF);
goto error;
}
}
@@ -451,6 +459,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
/* Retry the reading unless the remote was closed */
is_eof = ssh_channel_is_eof(sftp->channel);
if (is_eof) {
+ ssh_set_error(sftp->session,
+ SSH_REQUEST_DENIED,
+ "Received EOF while reading sftp packet");
+ sftp_set_error(sftp, SSH_FX_EOF);
goto error;
}
}