| 69 | }; |
| 70 | |
| 71 | static bool ParseAddress(std::string& address, |
| 72 | const fs::path& data_dir, |
| 73 | const std::string& dest_exe_name, |
| 74 | struct sockaddr_un& addr, |
| 75 | std::string& error) |
| 76 | { |
| 77 | if (address == "unix" || address.starts_with("unix:")) { |
| 78 | fs::path path; |
| 79 | if (address.size() <= 5) { |
| 80 | path = data_dir / fs::PathFromString(strprintf("%s.sock", RemovePrefixView(dest_exe_name, "bitcoin-"))); |
| 81 | } else { |
| 82 | path = data_dir / fs::PathFromString(address.substr(5)); |
| 83 | } |
| 84 | std::string path_str = fs::PathToString(path); |
| 85 | address = strprintf("unix:%s", path_str); |
| 86 | if (path_str.size() >= sizeof(addr.sun_path)) { |
| 87 | error = strprintf("Unix address path %s exceeded maximum socket path length", fs::quoted(fs::PathToString(path))); |
| 88 | return false; |
| 89 | } |
| 90 | memset(&addr, 0, sizeof(addr)); |
| 91 | addr.sun_family = AF_UNIX; |
| 92 | strncpy(addr.sun_path, path_str.c_str(), sizeof(addr.sun_path)-1); |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | error = strprintf("Unrecognized address '%s'", address); |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | int ProcessImpl::connect(const fs::path& data_dir, |
| 101 | const std::string& dest_exe_name, |
no test coverage detected