mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
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>
This commit is contained in:
committed by
Andreas Schneider
parent
58113d489e
commit
d78a29eb79
12
src/sftp.c
12
src/sftp.c
@@ -396,6 +396,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
|
|||||||
} else if (s == 0) {
|
} else if (s == 0) {
|
||||||
is_eof = ssh_channel_is_eof(sftp->channel);
|
is_eof = ssh_channel_is_eof(sftp->channel);
|
||||||
if (is_eof) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -416,6 +420,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
|
|||||||
} else if (nread == 0) {
|
} else if (nread == 0) {
|
||||||
is_eof = ssh_channel_is_eof(sftp->channel);
|
is_eof = ssh_channel_is_eof(sftp->channel);
|
||||||
if (is_eof) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,6 +459,10 @@ sftp_packet sftp_packet_read(sftp_session sftp)
|
|||||||
/* Retry the reading unless the remote was closed */
|
/* Retry the reading unless the remote was closed */
|
||||||
is_eof = ssh_channel_is_eof(sftp->channel);
|
is_eof = ssh_channel_is_eof(sftp->channel);
|
||||||
if (is_eof) {
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user