sftpserver: Avoid leaking fd and dir on allocation error

CID 1513160 and CID 1513159

Thanks coverity

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
Jakub Jelen
2023-06-20 14:20:17 +02:00
parent df0a445c87
commit e6d2b6c713

View File

@@ -905,6 +905,7 @@ process_open(sftp_client_message client_msg)
h = calloc(1, sizeof (struct sftp_handle));
if (h == NULL) {
close(fd);
SSH_LOG(SSH_LOG_PROTOCOL, "failed to allocate a new handle");
sftp_reply_status(client_msg, SSH_FX_FAILURE,
"Failed to allocate new handle");
@@ -1091,6 +1092,7 @@ process_opendir(sftp_client_message client_msg)
h = calloc(1, sizeof (struct sftp_handle));
if (h == NULL) {
closedir(dir);
SSH_LOG(SSH_LOG_PROTOCOL, "failed to allocate a new handle");
sftp_reply_status(client_msg, SSH_FX_FAILURE,
"Failed to allocate new handle");