]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Quote UDP tracker response error bodies with %#q v1.41.0
authorMatt Joiner <anacrolix@gmail.com>
Sun, 20 Feb 2022 05:15:45 +0000 (16:15 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 20 Feb 2022 05:15:45 +0000 (16:15 +1100)
tracker/udp/client.go

index c7f9392d36a7bab7df6d09719e2bc1a35ba54e88..0095a912aaac378995dd359f4bfa57d6d53e5380 100644 (file)
@@ -164,7 +164,9 @@ func (cl *Client) request(ctx context.Context, action Action, body []byte) (resp
                        respBody = dr.Body
                        addr = dr.Addr
                } else if dr.Header.Action == ActionError {
-                       err = fmt.Errorf("error response: %s", dr.Body)
+                       // I've seen "Connection ID mismatch.^@" in less and other tools, I think they're just
+                       // not handling a trailing \x00 nicely.
+                       err = fmt.Errorf("error response: %#q", dr.Body)
                } else {
                        err = fmt.Errorf("unexpected response action %v", dr.Header.Action)
                }