From 0448a19b1bb9ac615334aab0e82a8a963d81bbd8 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Fri, 26 Jul 2024 08:47:05 -0400 Subject: [PATCH] ipc: Improve -ipcconnect error checking When an invalid socket path is passed to -ipcconnect, either because the path exceeds the maximum socket length, or the path includes a directory component which is not actually a directory, treat this the same as the same as the socket refusing connections or not existing, instead of treating it like a more serious I/O error and throwing a fatal exception. This is needed to avoid CI errors after the following commit which adds a functional test and uses -datadir paths exceeding the maximum socket length when running in CI. --- src/ipc/interfaces.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ipc/interfaces.cpp b/src/ipc/interfaces.cpp index f40913d1853..1171f706487 100644 --- a/src/ipc/interfaces.cpp +++ b/src/ipc/interfaces.cpp @@ -95,10 +95,13 @@ public: fd = m_process->connect(gArgs.GetDataDirNet(), "bitcoin-node", address); } catch (const std::system_error& e) { // If connection type is auto and socket path isn't accepting connections, or doesn't exist, catch the error and return null; - if (e.code() == std::errc::connection_refused || e.code() == std::errc::no_such_file_or_directory) { + if (e.code() == std::errc::connection_refused || e.code() == std::errc::no_such_file_or_directory || e.code() == std::errc::not_a_directory) { return nullptr; } throw; + } catch (const std::invalid_argument&) { + // Catch 'Unix address path "..." exceeded maximum socket path length' error + return nullptr; } } else { fd = m_process->connect(gArgs.GetDataDirNet(), "bitcoin-node", address);