fix: prevent panic in MobileIdentity5GS getters on malformed input#43
Merged
Alonza0314 merged 5 commits intofree5gc:mainfrom Jan 21, 2026
Merged
Conversation
c9274326
reviewed
Jan 9, 2026
Comment on lines
150
to
152
| if len(a.Buffer) < 8 { | ||
| return "" | ||
| } |
There was a problem hiding this comment.
Hi @wiwi878, Please add fmt.Errorf() via func (a *MobileIdentity5GS) GetSUCI() (string, error) instead of return "" to provide error messages for callers.
Comment on lines
185
to
187
| if len(a.Buffer) < 9 { | ||
| return "" | ||
| } |
Comment on lines
220
to
222
| if len(a.Buffer) < 3 { | ||
| return "" | ||
| } |
Comment on lines
232
to
234
| if len(a.Buffer) < 4 { | ||
| return "" | ||
| } |
Comment on lines
253
to
255
| if len(a.Buffer) < 7 { | ||
| return "" | ||
| } |
nasType/NAS_MobileIdentity5GS.go
Outdated
Comment on lines
295
to
298
| } else if idType == "5G-S-TMSI" && err == nil { | ||
| amfPointerStartPoint = 2 | ||
| } else { | ||
| return "" |
nasType/NAS_MobileIdentity5GS.go
Outdated
Comment on lines
301
to
302
| if len(a.Buffer) <= amfPointerStartPoint { | ||
| return "" |
nasType/NAS_MobileIdentity5GS.go
Outdated
Comment on lines
314
to
316
| if len(a.Buffer) < 7 { | ||
| return "" | ||
| } |
Comment on lines
320
to
322
| if len(a.Buffer) < 7 { | ||
| return "" | ||
| } |
| } | ||
| } | ||
|
|
||
| type GetMobileIdentityTemplate struct { |
There was a problem hiding this comment.
After refactor some error message, maybe this go_test should be refactored too.
|
@Alonza0314 LGTM |
Alonza0314
approved these changes
Jan 21, 2026
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.
This PR is for issue#747 、 #769 、 #813