Merge pull request #748 from tmm1/patch-4

[host] Trim null bytes from unix.Uname() results
This commit is contained in:
Lomanic 2019-08-13 00:39:29 +02:00 committed by GitHub
commit 903a879e03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -380,7 +380,7 @@ func KernelVersionWithContext(ctx context.Context) (version string, err error) {
if err != nil {
return "", err
}
return string(utsname.Release[:]), nil
return string(utsname.Release[:bytes.IndexByte(utsname.Release[:], 0)]), nil
}
func getSlackwareVersion(contents []string) string {

View File

@ -3,11 +3,13 @@
package host
import (
"bytes"
"golang.org/x/sys/unix"
)
func kernelArch() (string, error) {
var utsname unix.Utsname
err := unix.Uname(&utsname)
return string(utsname.Machine[:]), err
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), err
}