1
1

sftp: Simplify the code for reading data

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Andreas Schneider 2018-09-07 21:55:17 +02:00
родитель afc14fe003
Коммит a7456bf4d5

Просмотреть файл

@ -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;
} }