fix: AVP decoding panic on dictionary/wire type mismatch#249
Open
masu-mi wants to merge 1 commit into
Open
Conversation
Two bugs caused panics when a received Diameter message contained AVPs whose wire payload differed from the dictionary definition. - diam/avp.go — In DecodeFromBytes, when the decoded type's Len() does not match the wire payload length, fall back to datatype. Unknown so that AVP.Len() returns the correct wire size and the parent parse loop advances by the right offset. - diam/group.go — In DecodeGroupedFromBytes, break out of the sub-AVP loop when a fatal decode error leaves avp.Data == nil, preventing a nil-interface panic in avp.Len().
fiorix
approved these changes
Jun 26, 2026
fiorix
left a comment
Owner
There was a problem hiding this comment.
Thanks, this is the right direction and covers the DecodeGrouped nil-Data panic class more completely than #235. Preserving malformed known AVPs as datatype.Unknown keeps the parent parse loop aligned, and the grouped fatal-error guard avoids the avp.Len() nil dereference.
I verified locally on bb5745d:
go test ./diamgo test ./...go test -race ./diamgo test -race ./...go vet ./diam/...
All passed. go vet ./... still reports the existing t.Fatalf-from-goroutine issue in examples/s6a_proxy/service/test, which is unrelated to this PR and already covered by #250.
The broader M-bit / DIAMETER_AVP_UNSUPPORTED / Failed-AVP behavior discussed on #235 should stay as a separate protocol-handling follow-up. No blocking comments from my pass.
Author
|
Thank you for thoughtful review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix 2 bugs caused panics when a received Diameter message contained AVPs whose wire payload differed from the dictionary definition.
Add regression tests.
bugs