ConSol-Monitoring / snclient

SNClient+ - Cross platform monitoring agent
MIT License
48 stars 9 forks source link

crash on ini file with only comments #58

Closed h4ppywastaken closed 9 months ago

h4ppywastaken commented 9 months ago

If snClient+ tries to load an ini file with only comment lines starting with ";" it crashes on service start. i.e. an ini file with only one line in it: ; INI Version 1

Expected Behavior

snClient loads the ini file and starts

Current Behavior

snClient loads the ini file and crashes

Context (Environment)

snClient Version: 0.12 Windows

Detailed Description

snClient crash dump:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x38 pc=0xa3ba42]

goroutine 1 [running]:
pkg/snclient.(*Config).ParseINI(0xc000095240, {0xdc03c0?, 0xc0000f53b0?}, {0xc0000c8d40, 0x34})
        pkg/snclient@v0.0.0-00010101000000-000000000000/config.go:259 +0x8c2
pkg/snclient.(*Config).ReadINI(0xc000095240, {0xc0000c8d40, 0x34})
        pkg/snclient@v0.0.0-00010101000000-000000000000/config.go:173 +0x4b0
pkg/snclient.(*Config).parseInclude(0xc000095240, {0xc00009ac48, 0x13}, {0xc0000c8440, 0x26})
        pkg/snclient@v0.0.0-00010101000000-000000000000/config.go:280 +0x295
pkg/snclient.(*Config).ParseINI(0xc000095240, {0xdc03c0?, 0xc0000f4ab0?}, {0xc0000c8440, 0x26})
        pkg/snclient@v0.0.0-00010101000000-000000000000/config.go:251 +0x5ac
pkg/snclient.(*Config).ReadINI(0xc000095240, {0xc0000c8440, 0x26})
        pkg/snclient@v0.0.0-00010101000000-000000000000/config.go:173 +0x4b0
pkg/snclient.(*Agent).readConfiguration(0xc0000a4500, {0xc0000989f0, 0x1, 0x1})
        pkg/snclient@v0.0.0-00010101000000-000000000000/snclient.go:422 +0x110
pkg/snclient.(*Agent).Init(0xc0000a4500)
        pkg/snclient@v0.0.0-00010101000000-000000000000/snclient.go:387 +0x1e5
pkg/snclient.NewAgent(0x12deb20)
        pkg/snclient@v0.0.0-00010101000000-000000000000/snclient.go:170 +0x25b
pkg/snclient/cmd.init.5.func1(0xc0000b1900?, {0xc9a235?, 0x4?, 0xc9a24d?})
        pkg/snclient/cmd@v0.0.0-00010101000000-000000000000/server.go:19 +0x29
github.com/spf13/cobra.(*Command).execute(0xc0000ea300, {0x1336140, 0x0, 0x0})
        github.com/spf13/cobra@v1.8.0/command.go:987 +0xaa3
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000d0600)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
pkg/snclient/cmd.Execute()
        pkg/snclient/cmd@v0.0.0-00010101000000-000000000000/root.go:87 +0x45
main.main()
        github.com/consol-monitoring/snclient/cmd/snclient/main.go:11 +0x13
sni commented 9 months ago

thanks for reporting this, this definitly should not happen

sni commented 9 months ago

should be fixed with latest nightly. Thanks again