Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cut scan length to 20 bytes #402

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions plugins/inputs/windows_event_log/wineventlog/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
eventLogQueryTemplate = `<QueryList><Query Id="0"><Select Path="%s">%s</Select></Query></QueryList>`
eventLogLevelFilter = "Level='%s'"
eventIgnoreOldFilter = "TimeCreated[timediff(@SystemTime) &lt;= %d]"
emptySpaceScanLength = 20

CRITICAL = "CRITICAL"
ERROR = "ERROR"
Expand Down Expand Up @@ -112,15 +113,15 @@ func UTF16ToUTF8Bytes(in []byte, length uint32) ([]byte, error) {
}

func isTheEndOfContent(in []byte, length uint32) bool {
// scan next 100 characters, if any of them is none '0', return false
// scan next 20 bytes, if any of them is none '0', return false
i := int(length)

if i%2 != 0 {
i -= 1
}
max := len(in)
if i+100 < max {
max = i+100
if i+emptySpaceScanLength < max {
max = i+emptySpaceScanLength
}

for ; i < max - 2; i += 2 {
Expand Down