mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
sftp: Simplify the code for reading data
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
16
src/sftp.c
16
src/sftp.c
@@ -394,16 +394,24 @@ sftp_packet sftp_packet_read(sftp_session sftp)
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/* TODO: check if there are cases where an error needs to be set here */
|
/* TODO: check if there are cases where an error needs to be set here */
|
||||||
goto error;
|
goto error;
|
||||||
} else if (r == 0) {
|
}
|
||||||
|
|
||||||
|
if (r > 0) {
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ssh_buffer_add_data(packet->payload, buffer, r);
|
||||||
|
if (rc != 0) {
|
||||||
|
ssh_set_error_oom(sftp->session);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else { /* r == 0 */
|
||||||
/* 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) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (ssh_buffer_add_data(packet->payload, buffer, r) == SSH_ERROR) {
|
|
||||||
ssh_set_error_oom(sftp->session);
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size -= r;
|
size -= r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user