Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
87f711a1
Commit
87f711a1
authored
6 years ago
by
Vlasta Hajek
Committed by
Daniel Nelson
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix panic with unicode counter names in win_perf_counters (#4255)
parent
58895d6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/inputs/win_perf_counters/performance_query.go
+1
-1
1 addition, 1 deletion
plugins/inputs/win_perf_counters/performance_query.go
plugins/inputs/win_perf_counters/win_perf_counters_test.go
+34
-0
34 additions, 0 deletions
plugins/inputs/win_perf_counters/win_perf_counters_test.go
with
35 additions
and
1 deletion
plugins/inputs/win_perf_counters/performance_query.go
+
1
−
1
View file @
87f711a1
...
...
@@ -181,7 +181,7 @@ func UTF16ToStringArray(buf []uint16) []string {
stringLine
:=
UTF16PtrToString
(
&
buf
[
0
])
for
stringLine
!=
""
{
strings
=
append
(
strings
,
stringLine
)
nextLineStart
+=
len
(
stringLine
)
+
1
nextLineStart
+=
len
(
[]
rune
(
stringLine
)
)
+
1
remainingBuf
:=
buf
[
nextLineStart
:
]
stringLine
=
UTF16PtrToString
(
&
remainingBuf
[
0
])
}
...
...
This diff is collapsed.
Click to expand it.
plugins/inputs/win_perf_counters/win_perf_counters_test.go
+
34
−
0
View file @
87f711a1
...
...
@@ -463,3 +463,37 @@ func TestGatherRefreshing(t *testing.T) {
acc3
.
AssertContainsTaggedFields
(
t
,
measurement
,
fields3
,
tags3
)
}
// list of nul terminated strings from WinAPI
var
unicodeStringListWithEnglishChars
=
[]
uint16
{
0x5c
,
0x5c
,
0x54
,
0x34
,
0x38
,
0x30
,
0x5c
,
0x50
,
0x68
,
0x79
,
0x73
,
0x69
,
0x63
,
0x61
,
0x6c
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x28
,
0x30
,
0x20
,
0x43
,
0x3a
,
0x29
,
0x5c
,
0x43
,
0x75
,
0x72
,
0x72
,
0x65
,
0x6e
,
0x74
,
0x20
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x20
,
0x51
,
0x75
,
0x65
,
0x75
,
0x65
,
0x20
,
0x4c
,
0x65
,
0x6e
,
0x67
,
0x74
,
0x68
,
0x0
,
0x5c
,
0x5c
,
0x54
,
0x34
,
0x38
,
0x30
,
0x5c
,
0x50
,
0x68
,
0x79
,
0x73
,
0x69
,
0x63
,
0x61
,
0x6c
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x28
,
0x5f
,
0x54
,
0x6f
,
0x74
,
0x61
,
0x6c
,
0x29
,
0x5c
,
0x43
,
0x75
,
0x72
,
0x72
,
0x65
,
0x6e
,
0x74
,
0x20
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x20
,
0x51
,
0x75
,
0x65
,
0x75
,
0x65
,
0x20
,
0x4c
,
0x65
,
0x6e
,
0x67
,
0x74
,
0x68
,
0x0
,
0x0
}
var
unicodeStringListWithCzechChars
=
[]
uint16
{
0x5c
,
0x5c
,
0x54
,
0x34
,
0x38
,
0x30
,
0x5c
,
0x46
,
0x79
,
0x7a
,
0x69
,
0x63
,
0x6b
,
0xfd
,
0x20
,
0x64
,
0x69
,
0x73
,
0x6b
,
0x28
,
0x30
,
0x20
,
0x43
,
0x3a
,
0x29
,
0x5c
,
0x41
,
0x6b
,
0x74
,
0x75
,
0xe1
,
0x6c
,
0x6e
,
0xed
,
0x20
,
0x64
,
0xe9
,
0x6c
,
0x6b
,
0x61
,
0x20
,
0x66
,
0x72
,
0x6f
,
0x6e
,
0x74
,
0x79
,
0x20
,
0x64
,
0x69
,
0x73
,
0x6b
,
0x75
,
0x0
,
0x5c
,
0x5c
,
0x54
,
0x34
,
0x38
,
0x30
,
0x5c
,
0x46
,
0x79
,
0x7a
,
0x69
,
0x63
,
0x6b
,
0xfd
,
0x20
,
0x64
,
0x69
,
0x73
,
0x6b
,
0x28
,
0x5f
,
0x54
,
0x6f
,
0x74
,
0x61
,
0x6c
,
0x29
,
0x5c
,
0x41
,
0x6b
,
0x74
,
0x75
,
0xe1
,
0x6c
,
0x6e
,
0xed
,
0x20
,
0x64
,
0xe9
,
0x6c
,
0x6b
,
0x61
,
0x20
,
0x66
,
0x72
,
0x6f
,
0x6e
,
0x74
,
0x79
,
0x20
,
0x64
,
0x69
,
0x73
,
0x6b
,
0x75
,
0x0
,
0x0
}
var
unicodeStringListSingleItem
=
[]
uint16
{
0x5c
,
0x5c
,
0x54
,
0x34
,
0x38
,
0x30
,
0x5c
,
0x50
,
0x68
,
0x79
,
0x73
,
0x69
,
0x63
,
0x61
,
0x6c
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x28
,
0x30
,
0x20
,
0x43
,
0x3a
,
0x29
,
0x5c
,
0x43
,
0x75
,
0x72
,
0x72
,
0x65
,
0x6e
,
0x74
,
0x20
,
0x44
,
0x69
,
0x73
,
0x6b
,
0x20
,
0x51
,
0x75
,
0x65
,
0x75
,
0x65
,
0x20
,
0x4c
,
0x65
,
0x6e
,
0x67
,
0x74
,
0x68
,
0x0
,
0x0
}
var
unicodeStringListNoItem
=
[]
uint16
{
0x0
}
var
stringArrayWithEnglishChars
=
[]
string
{
"
\\\\
T480
\\
PhysicalDisk(0 C:)
\\
Current Disk Queue Length"
,
"
\\\\
T480
\\
PhysicalDisk(_Total)
\\
Current Disk Queue Length"
,
}
var
stringArrayWithCzechChars
=
[]
string
{
"
\\\\
T480
\\
Fyzick
\u00fd
disk(0 C:)
\\
Aktu
\u00e1
ln
\u00ed
d
\u00e9
lka fronty disku"
,
"
\\\\
T480
\\
Fyzick
\u00fd
disk(_Total)
\\
Aktu
\u00e1
ln
\u00ed
d
\u00e9
lka fronty disku"
,
}
var
stringArraySingleItem
=
[]
string
{
"
\\\\
T480
\\
PhysicalDisk(0 C:)
\\
Current Disk Queue Length"
,
}
func
TestUTF16ToStringArray
(
t
*
testing
.
T
)
{
singleItem
:=
UTF16ToStringArray
(
unicodeStringListSingleItem
)
assert
.
True
(
t
,
assert
.
ObjectsAreEqual
(
singleItem
,
stringArraySingleItem
),
"Not equal single arrays"
)
noItem
:=
UTF16ToStringArray
(
unicodeStringListNoItem
)
assert
.
Nil
(
t
,
noItem
)
engStrings
:=
UTF16ToStringArray
(
unicodeStringListWithEnglishChars
)
assert
.
True
(
t
,
assert
.
ObjectsAreEqual
(
engStrings
,
stringArrayWithEnglishChars
),
"Not equal eng arrays"
)
czechStrings
:=
UTF16ToStringArray
(
unicodeStringListWithCzechChars
)
assert
.
True
(
t
,
assert
.
ObjectsAreEqual
(
czechStrings
,
stringArrayWithCzechChars
),
"Not equal czech arrays"
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment