Skip to content

fix: guard against nil profile in CALL_RESULT parsing#413

Open
rishabhvaish wants to merge 1 commit intolorenzodonini:masterfrom
rishabhvaish:fix/nil-profile-callresult-panic-313
Open

fix: guard against nil profile in CALL_RESULT parsing#413
rishabhvaish wants to merge 1 commit intolorenzodonini:masterfrom
rishabhvaish:fix/nil-profile-callresult-panic-313

Conversation

@rishabhvaish
Copy link
Copy Markdown

The CALL_RESULT handler in ParseMessage calls GetProfileForFeature on line 464 but discards the ok return value:
goprofile, _ := endpoint.GetProfileForFeature(request.GetFeatureName())
If the profile lookup fails, profile is nil and the immediate profile.ParseResponse(...) call panics with a nil pointer dereference. This can happen when a charge point responds with a CallResult for a feature whose profile isn't registered on the receiving endpoint.
The CALL handler already has the correct guard (line 439-441), so I've added the same check for the CALL_RESULT path. When no profile is found, it now returns an InternalError instead of crashing. Also added a test for this error path.
Fixes #313

The CALL_RESULT handler in ParseMessage called GetProfileForFeature
without checking the ok return value, causing a nil pointer panic when
the profile lookup fails. The CALL handler already had the correct
guard. Added the same check for CALL_RESULT responses and a test for
the new error path.

Closes lorenzodonini#313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server crashed when parsing ocpp message

1 participant