mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-07 02:39:48 +09:00
CVE-2025-5449 sftpserver: Avoid NULL dereference for invalid handles
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
a4118ddc06
commit
e322e8f50c
@@ -961,7 +961,7 @@ process_read(sftp_client_message client_msg)
|
||||
ssh_string_len(handle));
|
||||
|
||||
h = sftp_handle(sftp, handle);
|
||||
if (h->type == SFTP_FILE_HANDLE) {
|
||||
if (h != NULL && h->type == SFTP_FILE_HANDLE) {
|
||||
fd = h->fd;
|
||||
}
|
||||
|
||||
@@ -1019,7 +1019,7 @@ process_write(sftp_client_message client_msg)
|
||||
ssh_string_len(handle));
|
||||
|
||||
h = sftp_handle(sftp, handle);
|
||||
if (h->type == SFTP_FILE_HANDLE) {
|
||||
if (h != NULL && h->type == SFTP_FILE_HANDLE) {
|
||||
fd = h->fd;
|
||||
}
|
||||
if (fd < 0) {
|
||||
@@ -1064,7 +1064,11 @@ process_close(sftp_client_message client_msg)
|
||||
ssh_string_len(handle));
|
||||
|
||||
h = sftp_handle(sftp, handle);
|
||||
if (h->type == SFTP_FILE_HANDLE) {
|
||||
if (h == NULL) {
|
||||
SSH_LOG(SSH_LOG_PROTOCOL, "invalid handle");
|
||||
sftp_reply_status(client_msg, SSH_FX_INVALID_HANDLE, "Invalid handle");
|
||||
return SSH_OK;
|
||||
} else if (h->type == SFTP_FILE_HANDLE) {
|
||||
int fd = h->fd;
|
||||
close(fd);
|
||||
ret = SSH_OK;
|
||||
@@ -1232,7 +1236,7 @@ process_readdir(sftp_client_message client_msg)
|
||||
ssh_string_len(handle));
|
||||
|
||||
h = sftp_handle(sftp, client_msg->handle);
|
||||
if (h->type == SFTP_DIR_HANDLE) {
|
||||
if (h != NULL && h->type == SFTP_DIR_HANDLE) {
|
||||
dir = h->dirp;
|
||||
handle_name = h->name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user