1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-10 06:23:01 +03:00

fix sftp_new_channel constructs an invalid object

Fixes T273

Signed-off-by: Pablo Yaggi <pyaggi@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
Pablo Yaggi
2021-02-09 11:39:13 +00:00
committed by Jakub Jelen
parent 78036e98ec
commit 51b7a2421a

View File

@@ -191,14 +191,38 @@ sftp_new_channel(ssh_session session, ssh_channel channel)
sftp->ext = sftp_ext_new(); sftp->ext = sftp_ext_new();
if (sftp->ext == NULL) { if (sftp->ext == NULL) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
SAFE_FREE(sftp); goto error;
return NULL; }
sftp->read_packet = calloc(1, sizeof(struct sftp_packet_struct));
if (sftp->read_packet == NULL) {
ssh_set_error_oom(session);
goto error;
}
sftp->read_packet->payload = ssh_buffer_new();
if (sftp->read_packet->payload == NULL) {
ssh_set_error_oom(session);
goto error;
} }
sftp->session = session; sftp->session = session;
sftp->channel = channel; sftp->channel = channel;
return sftp; return sftp;
error:
if (sftp->ext != NULL) {
sftp_ext_free(sftp->ext);
}
if (sftp->read_packet != NULL) {
if (sftp->read_packet->payload != NULL) {
SSH_BUFFER_FREE(sftp->read_packet->payload);
}
SAFE_FREE(sftp->read_packet);
}
SAFE_FREE(sftp);
return NULL;
} }
#ifdef WITH_SERVER #ifdef WITH_SERVER