Skip to content

Commit

Permalink
btcjson,wire: fix invalid use of string(x) to convert byte value
Browse files Browse the repository at this point in the history
  • Loading branch information
federicobond authored and jakesylvestre committed Aug 31, 2020
1 parent d13e907 commit 35194e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion btcjson/cmdparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand Down
2 changes: 1 addition & 1 deletion wire/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 35194e2

Please sign in to comment.