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

panic in EvaluateThreshold because of unvalidated ParseRangeString return value #233

Closed
Tommi2Day opened this issue Jan 7, 2024 · 1 comment · Fixed by #236
Closed
Assignees
Labels
bug Something isn't working range
Milestone

Comments

@Tommi2Day
Copy link

Tommi2Day commented Jan 7, 2024

ParseRangeString may return NIL on errors, but in EvaluateThreshold this is not checked will lead to a panic

runtime error: invalid memory address or nil pointer dereference goroutine 36 [running]: runtime/debug.Stack() C:/Users/user/go-sdk/go1.21.3/src/runtime/debug/stack.go:24 +0x6b github.com/atc0005/go-nagios.(*Plugin).ReturnCheckResults(0xc0000c40e0) C:/local/progs/go-proj/src/check_hm/vendor/github.com/atc0005/go-nagios/nagios.go:283 +0x305 panic({0x1af6600?, 0x216afd0?}) C:/Users/user/go-sdk/go1.21.3/src/runtime/panic.go:920 +0x290 github.com/atc0005/go-nagios.(*Plugin).EvaluateThreshold(0xc0000c40e0, {0xc0001f16c0, 0x1, 0x1}) C:/local/progs/go-proj/src/check_hm/vendor/github.com/atc0005/go-nagios/range.go:153 +0xed
First

go-nagios/range.go

Lines 151 to 153 in 7a6e921

CriticalThresholdObject := ParseRangeString(perfData[i].Crit)
if CriticalThresholdObject.CheckRange(perfData[i].Value) {

may panic here if CritcalThreshold object is nil

second:

go-nagios/range.go

Lines 160 to 164 in 7a6e921

warningThresholdObject := ParseRangeString(perfData[i].Warn)
if warningThresholdObject.CheckRange(perfData[i].Value) {
p.ExitStatusCode = StateWARNINGExitCode
return nil

may panic here if warningThreshold object is nil

@atc0005 atc0005 self-assigned this Jan 8, 2024
@atc0005 atc0005 added bug Something isn't working range labels Jan 8, 2024
@atc0005
Copy link
Owner

atc0005 commented Jan 8, 2024

@Tommi2Day,

Thank you for this report. I appreciate the specifics you have provided.

@infraweavers,

Any interest in taking a look at this? If you use a modified version of the code contributed in GH-178 is it publicly available?

I figured it was best to touch base with you to see if this was already resolved in a private branch before digging into it.

Thanks.

Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 14, 2024
@atc0005 atc0005 added this to the Next Release milestone Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 16, 2024
Tommi2Day pushed a commit to Tommi2Day/go-nagios that referenced this issue Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working range
Projects
None yet
2 participants