From 97cfeb682de5aa2e959bd29b48c6f65ee18070b0 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 27 Aug 2020 16:11:21 -0300 Subject: [PATCH 1/2] btcd: fix conversion of int to string failing in Go 1.15 --- upnp.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/upnp.go b/upnp.go index feb256d072..c74e4ed79a 100644 --- a/upnp.go +++ b/upnp.go @@ -36,6 +36,7 @@ import ( "bytes" "encoding/xml" "errors" + "fmt" "net" "net/http" "os" @@ -229,7 +230,7 @@ func getServiceURL(rootURL string) (url string, err error) { } defer r.Body.Close() if r.StatusCode >= 400 { - err = errors.New(string(r.StatusCode)) + err = errors.New(fmt.Sprint(r.StatusCode)) return } var root root From 09d2508067e74b8b249beeb259fbc5e1ef73ea7a Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 27 Aug 2020 21:30:27 -0300 Subject: [PATCH 2/2] btcjson,wire: fix invalid use of string(x) to convert byte value --- btcjson/cmdparse_test.go | 2 +- wire/message.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/btcjson/cmdparse_test.go b/btcjson/cmdparse_test.go index 7c13a0bb44..dd951dcbd7 100644 --- a/btcjson/cmdparse_test.go +++ b/btcjson/cmdparse_test.go @@ -201,7 +201,7 @@ func TestAssignFieldErrors(t *testing.T) { }{ { name: "general incompatible int -> string", - dest: string(0), + dest: "\x00", src: int(0), err: btcjson.Error{ErrorCode: btcjson.ErrInvalidType}, }, diff --git a/wire/message.go b/wire/message.go index e937647702..fe45a11fb1 100644 --- a/wire/message.go +++ b/wire/message.go @@ -213,7 +213,7 @@ func readMessageHeader(r io.Reader) (int, *messageHeader, error) { readElements(hr, &hdr.magic, &command, &hdr.length, &hdr.checksum) // Strip trailing zeros from command string. - hdr.command = string(bytes.TrimRight(command[:], string(0))) + hdr.command = string(bytes.TrimRight(command[:], "\x00")) return n, &hdr, nil }