diff --git a/hostinfo/hostinfo_freebsd.go b/hostinfo/hostinfo_freebsd.go index f97fb762e..ffb7417c1 100644 --- a/hostinfo/hostinfo_freebsd.go +++ b/hostinfo/hostinfo_freebsd.go @@ -27,12 +27,7 @@ func osVersionFreebsd() string { var attrBuf strings.Builder attrBuf.WriteString("; version=") - for _, b := range un.Release { - if b == 0 { - break - } - attrBuf.WriteByte(byte(b)) - } + attrBuf.WriteString(unix.ByteSliceToString(un.Release[:])) attr := attrBuf.String() version := "FreeBSD" diff --git a/hostinfo/hostinfo_linux.go b/hostinfo/hostinfo_linux.go index a659490b9..9028cd696 100644 --- a/hostinfo/hostinfo_linux.go +++ b/hostinfo/hostinfo_linux.go @@ -14,6 +14,7 @@ "os" "strings" + "golang.org/x/sys/unix" "tailscale.com/util/lineread" "tailscale.com/version/distro" ) @@ -72,12 +73,7 @@ func osVersionLinux() string { var attrBuf strings.Builder attrBuf.WriteString("; kernel=") - for _, b := range un.Release { - if b == 0 { - break - } - attrBuf.WriteByte(byte(b)) - } + attrBuf.WriteString(unix.ByteSliceToString(un.Release[:])) if inContainer() { attrBuf.WriteString("; container") }