From 9b5a75528ecf12429b8992595c5fa9e77bdb9917 Mon Sep 17 00:00:00 2001 From: LaserEyess <16581533+LaserEyess@users.noreply.github.com> Date: Sat, 24 Jun 2023 14:57:20 -0400 Subject: [PATCH] fix: broken unix socket support (#5665) The changes in #5523 made two errors in the new implementation 1. tr_unix_address::to_string() got the ternary check backwards, leading to always printing an empty string when the address is valid. 2. The inputs to tr_strvStartsWith in tr_unix_address::from_string() were backwards as well, leading to the check failing for valid socket addresses. Co-authored-by: LaserEyess --- libtransmission/rpc-server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libtransmission/rpc-server.cc b/libtransmission/rpc-server.cc index a500634f8..99f9920bf 100644 --- a/libtransmission/rpc-server.cc +++ b/libtransmission/rpc-server.cc @@ -86,12 +86,12 @@ class tr_unix_addr public: [[nodiscard]] std::string to_string() const { - return std::empty(unix_socket_path_) ? unix_socket_path_ : std::string(TrUnixSocketPrefix); + return std::empty(unix_socket_path_) ? std::string(TrUnixSocketPrefix) : unix_socket_path_; } [[nodiscard]] bool from_string(std::string_view src) { - if (!tr_strvStartsWith(TrUnixSocketPrefix, src)) + if (!tr_strvStartsWith(src, TrUnixSocketPrefix)) { return false; }