Change in libosmocore[master]: ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parse

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Mar 28 12:22:37 UTC 2019


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/13431 )

Change subject: ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parse
......................................................................

ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parse

ipa_ccm_idtag_parse_off is broken, and can only be used with
len_offset=1 on ID Request messages, otherwise won't work correctly.
Modify ipa_ccm_idtag_parse to at least parse those correctly, and
document the limitations.

Those two functions are already deprecated and only used in openbsc by 3
callers:
* ipa_ccm_idtag_parse in ussd_read_cb(): Broken, that function can only
work for Requests and it's used to parse a Response.
* ipa_ccm_idtag_parse_off in forward_sccp_to_msc (NAT): Broken, it can
only be used to parse Requests and it's used to parse a Response.
Furthermore, len_offset=2 is passed which makes no sense and most
probably it fails always, or can even make the program crash.
* ipa_ccm_idtag_parse_off in (answer_challenge): This one is fine and
could actually be replaced with ipa_ccm_id_get_parse after this commit
is merged.

Change-Id: I6efc852dfc041192f554e41a58290a0f63298021
---
M src/gsm/ipa.c
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index d423c26..8e64a1e 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -98,11 +98,21 @@
 	return idtag_names[tag];
 }
 
+/*! Parse the payload part of an IPA CCM ID GET, return \ref tlv_parsed format. */
 int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
 {
-	return ipa_ccm_idtag_parse_off(dec, buf, len, 0);
+	return ipa_ccm_idtag_parse_off(dec, buf, len, 1);
 }
 
+/*! Parse the payload part of an IPA CCM ID GET, return \ref tlv_parsed format.
+ *	WARNING: This function can only parse correctly IPA CCM ID GET/REQUEST
+ *	messages, and only when len_offset is passed value of 1.
+ *  \param[out] dec Caller-provided/allocated output structure for parsed payload
+ *  \param[in] buf Buffer containing the payload (excluding 1 byte msg_type) of the message
+ *  \param[in] len Length of \a buf in octets
+ *  \param[in] len_offset Offset from end of len field to start of value (ommiting tag). Must be 1!
+ *  \returns 0 on success; negative on error
+ */
 int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset)
 {
 	uint8_t t_len;

-- 
To view, visit https://gerrit.osmocom.org/13431
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6efc852dfc041192f554e41a58290a0f63298021
Gerrit-Change-Number: 13431
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190328/c37cbf7d/attachment.html>


More information about the gerrit-log mailing list