1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

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 <LaserEyess@users.noreply.github.com>
This commit is contained in:
LaserEyess 2023-06-24 14:57:20 -04:00 committed by GitHub
parent 46dac775e0
commit 9b5a75528e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}