From b254f75968e1a5692fa872fcfda5eaa1a0ed561d Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 16 Oct 2024 09:49:55 +0200 Subject: safer path from handle (#195) * remove PathFromHandle that throws to give better context on failures --- src/zenhttp/httpclient.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/zenhttp/httpclient.cpp') diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp index 7ac0028cc..0d12cf815 100644 --- a/src/zenhttp/httpclient.cpp +++ b/src/zenhttp/httpclient.cpp @@ -367,8 +367,18 @@ public: SetFileInformationByHandle(m_FileHandle, FileDispositionInfo, &Fdi, sizeof Fdi); BOOL Success = CloseHandle(m_FileHandle); #else - std::filesystem::path FilePath = zen::PathFromHandle(m_FileHandle); - unlink(FilePath.c_str()); + std::error_code Ec; + std::filesystem::path FilePath = zen::PathFromHandle(m_FileHandle, Ec); + if (Ec) + { + ZEN_WARN("Error reported on get file path from handle {} for temp payload unlink operation, reason '{}'", + m_FileHandle, + Ec.message()); + } + else + { + unlink(FilePath.c_str()); + } int Fd = int(uintptr_t(m_FileHandle)); bool Success = (close(Fd) == 0); #endif -- cgit v1.2.3