mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user