From 35194e2dacf8c918abe77ac85ca220cc8a9fd1e6 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 27 Aug 2020 21:30:27 -0300 Subject: [PATCH] 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 }