Skip to content

getContentID: reject empty multipart class discriminator instead of slice-panic#71

Merged
Alonza0314 merged 2 commits into
free5gc:mainfrom
SAY-5:say5/get-content-id-empty-discriminator-1039
May 7, 2026
Merged

getContentID: reject empty multipart class discriminator instead of slice-panic#71
Alonza0314 merged 2 commits into
free5gc:mainfrom
SAY-5:say5/get-content-id-empty-discriminator-1039

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 2, 2026

Fixes free5gc/free5gc#1039.

getContentID constructs a Go field name from a multipart class= discriminator by slicing fieldName[:1]. When the resolved discriminator is an empty string — sent as "" by the client, or trimmed to "" by the dash-prefix handler at line 254 — the slice panics with slice bounds out of range [:1] with length 0 and crashes any NF whose multipart deserialization path runs through this helper (AMF N1N2MessageTransfer and any other endpoint using a discriminator-derived Content-Id tag).

Reject the empty case with a clear error so callers see a 4xx instead of the NF crashing.

…panic

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@d11nn
Copy link
Copy Markdown
Contributor

d11nn commented May 6, 2026

@chchen7 @wiwi878 PTAL

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
@SAY-5
Copy link
Copy Markdown
Contributor Author

SAY-5 commented May 6, 2026

Done — trimmed verbose comments and moved context to the PR description. Thanks @roundspring2003!

@roundspring2003
Copy link
Copy Markdown
Contributor

@Alonza0314 LGTM

@roundspring2003 roundspring2003 requested a review from Alonza0314 May 7, 2026 07:16
@Alonza0314 Alonza0314 merged commit 5ac3c0a into free5gc:main May 7, 2026
1 check 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.

[Bugs] MultiNF openapi getContentID L256 slice bounds panic

4 participants