Commit bfd4ef9
fix(ngap): add nil guards for three remaining NGAP handlers (#708)
* fix(ngap): add nil guards for three remaining NGAP handlers
Follow-up to PR #666. Three handlers still dereference mandatory IE
pointers (rANUENGAPID, aMFUENGAPID) without a post-loop nil guard, so
a malformed NGAP message that omits the IE entirely from
ProtocolIEs.List crashes the AMF.
The in-loop checks only catch "IE present but value nil" — they log
and continue instead of returning, leaving the variable nil for the
post-loop dereference.
Handlers fixed:
- HandlePDUSessionResourceNotify: guard rANUENGAPID, aMFUENGAPID
- HandleHandoverFailure: guard aMFUENGAPID
- HandleUplinkRanStatusTransfer: guard rANUENGAPID
FetchRanUeContext dispatches PDUSessionResourceNotify and
UplinkRANStatusTransfer but does not nil-check aMFUENGAPID for the
former and does not parse IEs at all for the latter (empty case).
HandoverFailure arrives in UnsuccessfulOutcome which the dispatcher
does not pre-process.
Signed-off-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
* fix(ngap): address Copilot review on PR #708
- HandlePDUSessionResourceNotify: also guard pDUSessionResourceNotifyList
before iterating its .List field. Without the guard, a message that
omits this mandatory IE (or includes it with a nil value) still
panics on the post-loop range.
- HandleHandoverFailure: synthesize a default Cause when the IE is
missing. Cause is later dereferenced via *cause when calling
SendHandoverPreparationFailure; falling back to the same default
(causePresent / causeValue) already used for the SendUEContextRelease
path keeps the function crash-safe.
- Add tests for the three handlers, matching the style of the existing
TestHandleHandoverNotifyIgnoresMissingIDs / TestHandleHandoverRequestAcknowledgeIgnoresMissingAmfUeNgapID.
Signed-off-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
* test(ngap): fix HandoverFailure outcome symbols for ngap/v2 v2.1.0
The TestHandleHandoverFailureIgnoresMissingIEs test referenced the
ngap/v2 v2.0.0 names for the HandoverFailure unsuccessful outcome,
which broke compilation after the dependency was bumped to v2.1.0
(via #711). In v2.1.0 the regenerated ngapType package renamed the
outcome to HandoverResourceAllocation:
- UnsuccessfulOutcomePresentHandoverFailure
-> UnsuccessfulOutcomePresentHandoverResourceAllocation
- UnsuccessfulOutcomeValue.HandoverFailure
-> UnsuccessfulOutcomeValue.HandoverResourceAllocation
The *HandoverFailure struct type itself is unchanged. This fixes the
lint, staticcheck, and unit-tests CI failures on PR #708.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
---------
Signed-off-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
Co-authored-by: Vinod Patmanathan <vinod.patmanathan@forsway.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 64aa74e commit bfd4ef9
2 files changed
Lines changed: 97 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2103 | 2103 | | |
2104 | 2104 | | |
2105 | 2105 | | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
2106 | 2119 | | |
2107 | 2120 | | |
2108 | 2121 | | |
| |||
3611 | 3624 | | |
3612 | 3625 | | |
3613 | 3626 | | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
3614 | 3635 | | |
3615 | 3636 | | |
3616 | 3637 | | |
3617 | 3638 | | |
3618 | 3639 | | |
3619 | 3640 | | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
3620 | 3646 | | |
3621 | 3647 | | |
3622 | 3648 | | |
| |||
4040 | 4066 | | |
4041 | 4067 | | |
4042 | 4068 | | |
| 4069 | + | |
| 4070 | + | |
| 4071 | + | |
| 4072 | + | |
| 4073 | + | |
4043 | 4074 | | |
4044 | 4075 | | |
4045 | 4076 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
75 | 141 | | |
76 | 142 | | |
77 | 143 | | |
| |||
0 commit comments