diff --git a/internal/util/util.go b/internal/util/util.go index bb4163486..b8e1b387a 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -148,7 +148,7 @@ func KernelVersion() (string, error) { if err != nil { return "", err } - return string(utsname.Release[:]), nil + return strings.TrimRight(string(utsname.Release[:]), "\x00"), nil } // GenerateVolID generates a volume ID based on passed in parameters and version, to be returned diff --git a/internal/util/util_test.go b/internal/util/util_test.go index a8451883c..52a113218 100644 --- a/internal/util/util_test.go +++ b/internal/util/util_test.go @@ -16,6 +16,7 @@ limitations under the License. package util import ( + "strings" "testing" ) @@ -151,4 +152,7 @@ func TestKernelVersion(t *testing.T) { if version == "" { t.Error("version is empty, this is unexpected?!") } + if strings.HasSuffix(version, "\x00") { + t.Error("version ends with \\x00 byte(s)") + } }