<p>Pau Espin Pedrol has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13431">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parse<br><br>ipa_ccm_idtag_parse_off is broken, and can only be used with<br>len_offset=1 on ID Request messages, otherwise won't work correctly.<br>Modify ipa_ccm_idtag_parse to at least parse those correctly, and<br>document the limitations.<br><br>Those two functions are already deprecated and only used in openbsc by 3<br>callers:<br>* ipa_ccm_idtag_parse in ussd_read_cb(): Broken, that function can only<br>work for Requests and it's used to parse a Response.<br>* ipa_ccm_idtag_parse_off in forward_sccp_to_msc (NAT): Broken, it can<br>only be used to parse Requests and it's used to parse a Response.<br>Furthermore, len_offset=2 is passed which makes no sense and most<br>probably it fails always, or can even make the program crash.<br>* ipa_ccm_idtag_parse_off in (answer_challenge): This one is fine and<br>could actually be replaced with ipa_ccm_id_get_parse after this commit<br>is merged.<br><br>Change-Id: I6efc852dfc041192f554e41a58290a0f63298021<br>---<br>M src/gsm/ipa.c<br>1 file changed, 11 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/13431/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c</span><br><span>index d423c26..8e64a1e 100644</span><br><span>--- a/src/gsm/ipa.c</span><br><span>+++ b/src/gsm/ipa.c</span><br><span>@@ -98,11 +98,21 @@</span><br><span>       return idtag_names[tag];</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Parse the payload part of an IPA CCM ID GET, return \ref tlv_parsed format. */</span><br><span> int ipa_ccm_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-      return ipa_ccm_idtag_parse_off(dec, buf, len, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+     return ipa_ccm_idtag_parse_off(dec, buf, len, 1);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*! Parse the payload part of an IPA CCM ID GET, return \ref tlv_parsed format.</span><br><span style="color: hsl(120, 100%, 40%);">+ * WARNING: This function can only parse correctly IPA CCM ID GET/REQUEST</span><br><span style="color: hsl(120, 100%, 40%);">+ *      messages, and only when len_offset is passed value of 1.</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[out] dec Caller-provided/allocated output structure for parsed payload</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] buf Buffer containing the payload (excluding 1 byte msg_type) of the message</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len Length of \a buf in octets</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \param[in] len_offset Offset from end of len field to start of value (ommiting tag). Must be 1!</span><br><span style="color: hsl(120, 100%, 40%);">+ *  \returns 0 on success; negative on error</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span> int ipa_ccm_idtag_parse_off(struct tlv_parsed *dec, unsigned char *buf, int len, const int len_offset)</span><br><span> {</span><br><span>       uint8_t t_len;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13431">change 13431</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13431"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I6efc852dfc041192f554e41a58290a0f63298021 </div>
<div style="display:none"> Gerrit-Change-Number: 13431 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>