diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index f8db8c52f822..aecd47192769 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -164,6 +164,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] *Winlogbeat* +- Fix EvtVarTypeAnsiString conversion {pull}44026[44026] *Elastic Logging Plugin* diff --git a/winlogbeat/sys/strings_windows.go b/winlogbeat/sys/strings_windows.go index 0ce8b09f5d63..bdfa4c897c68 100644 --- a/winlogbeat/sys/strings_windows.go +++ b/winlogbeat/sys/strings_windows.go @@ -18,6 +18,7 @@ package sys import ( + "bytes" "sync" "golang.org/x/sys/windows" @@ -48,6 +49,8 @@ func initANSIDecoder() *encoding.Decoder { } func ANSIBytesToString(enc []byte) (string, error) { - out, err := getCachedANSIDecoder().Bytes(enc) + // Trim to the null terminator + prefix, _, _ := bytes.Cut(enc, []byte("\x00")) + out, err := getCachedANSIDecoder().Bytes(prefix) return string(out), err }