fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39388?usp=email )


Change subject: s1ap_proxy: fix IEI path leak in handle_ies/4
......................................................................

s1ap_proxy: fix IEI path leak in handle_ies/4

Function handle_ies/3 prepends a new item to the IEI path and calls
function handle_ies/4.  The later was expected to remove that item
from the IEI path upon returning the new #proxy_state.

This was done correctly in the successful scenario, however the
error case was overlooked in 00f51fe.  As a result of this, whenever
handle_ie/3 returns an error, the IEI path is not properly cleaned
and stale IEIs remain in the #proxy_state.

Fix this by removing the head IEI in the same place where we push it.

Change-Id: I64629a215c05e8d577a8943ae872945d61b5107c
Fixes: 00f51fe ("s1ap_proxy: handle_ies(): pass IEI path to handle_ie()")
Related: SYS#7288
---
M src/s1ap_proxy.erl
1 file changed, 8 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw 
refs/changes/88/39388/1

diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index 365f141..f04fb61 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -578,8 +578,12 @@
 %% Additionally look for {MME,eNB}-UE-S1AP-ID IEs and store their values.
 -type handle_ies_result() :: {ok, list()} | {error, term()}.
 -spec handle_ies(s1ap_ie_id(), list(), proxy_state()) -> {handle_ies_result(), 
proxy_state()}.
-handle_ies(IEI, IEs, #proxy_state{path = P} = S) ->
-    handle_ies([], IEI, IEs, S#proxy_state{path = [IEI | P]}).
+handle_ies(IEI, IEs, #proxy_state{path = P} = S0) ->
+    %% prepend IEI to the path and call handle_ies/4
+    {Result, S1} = handle_ies([], IEI, IEs,
+                              S0#proxy_state{path = [IEI | P]}),
+    %% remove IEI from the path and return the result
+    {Result, S1#proxy_state{path = P}}.

 handle_ies(Acc, IEI, [IE | IEs],
            #proxy_state{path = P} = S0) ->
@@ -610,10 +614,9 @@
             handle_ies([IE | Acc], IEI, IEs, S0)
     end;

-handle_ies(Acc, IEI, [],
-           #proxy_state{path = [IEI | P]} = S) ->
+handle_ies(Acc, _IEI, [], S) ->
     IEs = lists:reverse(Acc),
-    {{ok, IEs}, S#proxy_state{path = P}}.
+    {{ok, IEs}, S}.


 build_erab_setup_response_failure(#proxy_state{erabs = ERABs,

--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39388?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I64629a215c05e8d577a8943ae872945d61b5107c
Gerrit-Change-Number: 39388
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>

Reply via email to