From 5d1acdc455cb539d6139344d9247c7afa36554ae Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 2 Feb 2023 08:27:53 -0500 Subject: [PATCH] FileSystemAccessServer: Send correct error code for failed file access When a file cannot be accessed, we currently send errno as the error code. However, there are system calls which occur (by way of dbgln) between the failed file access and accessing errno. This prevents the client-side detection of ENOENT from working. Instead, send over the error we already have stored in the ErrorOr object. --- .../Services/FileSystemAccessServer/ConnectionFromClient.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp index 6899e44288..d368182a24 100644 --- a/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp +++ b/Userland/Services/FileSystemAccessServer/ConnectionFromClient.cpp @@ -94,7 +94,7 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve if (file.is_error()) { dbgln("FileSystemAccessServer: Couldn't open {}, error {}", path, file.error()); - async_handle_prompt_end(request_id, errno, Optional {}, path); + async_handle_prompt_end(request_id, file.error().code(), Optional {}, path); } else { async_handle_prompt_end(request_id, 0, IPC::File(*file.release_value(), IPC::File::CloseAfterSending), path); } @@ -145,8 +145,7 @@ void ConnectionFromClient::prompt_helper(i32 request_id, Optional {}, user_picked_file); + async_handle_prompt_end(request_id, file.error().code(), Optional {}, user_picked_file); } else { auto maybe_permissions = m_approved_files.get(user_picked_file.value()); auto new_permissions = requested_access & (Core::Stream::OpenMode::Read | Core::Stream::OpenMode::Write);