pespin has uploaded this change for review.

View Change

ipa: fix empty IPA CCM ID Tags

decode_ies() would crash because lists:lasts([]) tries to access an
empty lists.

Change-Id: I6f44561f83c84bac7e5c98747f969f5436617f90
---
M src/ipa_proto_ccm.erl
1 file changed, 18 insertions(+), 3 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/erlang/osmo_ss7 refs/changes/05/36105/1
diff --git a/src/ipa_proto_ccm.erl b/src/ipa_proto_ccm.erl
index 27ceba9..87eb15e 100644
--- a/src/ipa_proto_ccm.erl
+++ b/src/ipa_proto_ccm.erl
@@ -82,9 +82,12 @@
decode_ies(<<0:8, Len:8, TypeValue:Len/binary, Remain/binary>>, IeList) when is_list(IeList) ->
<<Type:8, Value/binary>> = TypeValue,
ValueList = binary_to_list(Value),
- case lists:last(ValueList) of
- 0 -> ValueStripped = lists:droplast(ValueList);
- _ -> ValueStripped = ValueList
+ case ValueList of
+ [] -> ValueStripped = [];
+ _ -> case lists:last(ValueList) of
+ 0 -> ValueStripped = lists:droplast(ValueList);
+ _ -> ValueStripped = ValueList
+ end
end,
decode_ies(Remain, IeList ++ [{string, decode_idtag(Type), ValueStripped}]).


To view, visit change 36105. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: erlang/osmo_ss7
Gerrit-Branch: master
Gerrit-Change-Id: I6f44561f83c84bac7e5c98747f969f5436617f90
Gerrit-Change-Number: 36105
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-CC: lynxis lazus <lynxis@fe80.eu>
Gerrit-MessageType: newchange