Skip to content

Comments

fix: prevent panic in MobileIdentity5GS getters on malformed input#43

Merged
Alonza0314 merged 5 commits intofree5gc:mainfrom
wiwi878:fix/nas-mobile-identity-panic
Jan 21, 2026
Merged

fix: prevent panic in MobileIdentity5GS getters on malformed input#43
Alonza0314 merged 5 commits intofree5gc:mainfrom
wiwi878:fix/nas-mobile-identity-panic

Conversation

@wiwi878
Copy link
Contributor

@wiwi878 wiwi878 commented Dec 29, 2025

This PR is for issue#747 、 #769 、 #813

Comment on lines 150 to 152
if len(a.Buffer) < 8 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 220 to 222
if len(a.Buffer) < 3 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 232 to 234
if len(a.Buffer) < 4 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 253 to 255
if len(a.Buffer) < 7 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 295 to 298
} else if idType == "5G-S-TMSI" && err == nil {
amfPointerStartPoint = 2
} else {
return ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 301 to 302
if len(a.Buffer) <= amfPointerStartPoint {
return ""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 314 to 316
if len(a.Buffer) < 7 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

Comment on lines 320 to 322
if len(a.Buffer) < 7 {
return ""
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above mentioned

}
}

type GetMobileIdentityTemplate struct {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After refactor some error message, maybe this go_test should be refactored too.

@c9274326
Copy link

@Alonza0314 LGTM

@Alonza0314 Alonza0314 merged commit 0329a7a into free5gc:main Jan 21, 2026
2 checks passed
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.

3 participants