Skip to content

Commit

Permalink
reland Werk 17196
Browse files Browse the repository at this point in the history
Change-Id: I71feae334929716d7048faa143b5a28f93cf092e
  • Loading branch information
mo-ki committed Oct 29, 2024
1 parent 7acd950 commit 08c6a49
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 11 additions & 0 deletions .werks/17196
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Title: Crash in during HW/SW inventory on Windows
Class: fix
Compatible: compat
Component: checks
Date: 1728416670
Edition: cre
Level: 1
Version: 2.2.0p36

This fixes a crash in case software package names contained a pipe character (<code>|</code>).
Affected users need to redeploy the Checkmk agent.
12 changes: 6 additions & 6 deletions agents/windows/plugins/mk_inventory.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Sub SoftwareFromInstaller(fields)
idx = idx + 1
Next

outPut(Join(values, "|"))
outPut(Join(values, Chr(0)))
else
'Products function
Err.clear()
Expand All @@ -262,7 +262,7 @@ Sub SoftwareFromInstaller(fields)
idx = idx + 1
Next

outPut(Join(values, "|"))
outPut(Join(values, Chr(0)))
end if
Next
End Sub
Expand Down Expand Up @@ -321,7 +321,7 @@ Call startSection("win_ip_r",124,timeUntil)
Call getRouteTable()

' Installed Software
Call startSection("win_wmi_software",124,timeUntil)
Call startSection("win_wmi_software",0,timeUntil)
swVars = Array( "ProductName", "Publisher", "VersionString", "InstallDate", "Language")
Call SoftwareFromInstaller(swVars)

Expand All @@ -335,7 +335,7 @@ Do While Not objExecObject.StdOut.AtEndOfStream
Loop

' Search Registry
Call startSection("win_reg_uninstall",124,timeUntil)
Call startSection("win_reg_uninstall",0,timeUntil)
Set rego = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
regVars = Array("DisplayName", "Publisher", "InstallLocation", "PSChildName", "DisplayVersion", "EstimatedSize", "InstallDate", "Language")

Expand All @@ -359,13 +359,13 @@ For Each path in regPaths
End If
' Only allow vartypes which can be represented as a string
If VarType(value) <= 8 and VarType(value) > 1 Then
strOut = strOut & "|" & CStr(value)
strOut = strOut & Chr(0) & CStr(value)
' Only print a line when more than only PSChildName is present
If var <> "PSChildName" Then
boleanContent = True
End If
Else
strOut = strOut & "|"
strOut = strOut & Chr(0)
End If
Next
If boleanContent Then
Expand Down

0 comments on commit 08c6a49

Please sign in to comment.