ipc: Improve -ipcconnect error checking
What changed, and why it matters
This change makes Bitcoin Core handle two specific invalid -ipcconnect socket path cases more gracefully. Previously, a socket path that was too long or pointed to a non-directory component would crash the process with a fatal error. Now, when the connection type is set to 'auto', these cases are treated like a missing or refusing socket, and the program simply returns null instead of crashing. The commit message says this is mainly to avoid CI test failures caused by long data directory paths, not to fix a security vulnerability.
No immediate action required. Treat as a minor robustness improvement. If reviewing, verify that silently returning nullptr on invalid_argument does not mask other configuration errors that users should be notified about.
Security signals we found
Change reduces fatal exceptions for invalid local socket paths
No memory safety, cryptographic, or network trust-boundary changes
Commit message frames change as CI/test robustness, not security fix
Evidence from the diff
In src/ipc/interfaces.cpp, the exception handling around m_process->connect() is expanded. A std::invalid_argument catch block is added to handle the ‘Unix address path exceeded maximum socket path length’ error, and std::errc::not_a_directory is added to the existing std::system_error condition. Both now return nullptr instead of rethrowing and causing a fatal exception. This only affects behavior when -ipcconnect=auto is used.
Changed components
src/ipc/interfaces.cppBitcoin Core IPC client connection logic-ipcconnect option handlingInspect captured patch +4 / −1
diff --git a/src/ipc/interfaces.cpp b/src/ipc/interfaces.cpp
index f40913d1..1171f706 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);
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.