<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-msc/+/19098">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sgs_tx_loc_upd_resp_cb(): fix error handling for MI encoding<br><br>new_id_ptr should be passed as NULL if encoding the TMSI failed, so initialize<br>it accordingly.<br><br>Also add some bloat to better handle the case of an encoding error, even though<br>from code analysis that should not be possible here: there is enough buffer,<br>the MI is a TMSI encoded from a uint32_t...<br><br>The problem was introduced by Idfc8e576e10756aeaacf5569f6178068313eb7ea, before<br>which new_id_len was always 0 when no TMSI was present.<br><br>Related: CID#210894<br>Change-Id: I800c5dca3fdbdedf70a64d9fd5a1bdfd1397f431<br>---<br>M src/libmsc/sgs_iface.c<br>1 file changed, 8 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/98/19098/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libmsc/sgs_iface.c b/src/libmsc/sgs_iface.c</span><br><span>index b792e46..d13449d 100644</span><br><span>--- a/src/libmsc/sgs_iface.c</span><br><span>+++ b/src/libmsc/sgs_iface.c</span><br><span>@@ -372,7 +372,7 @@</span><br><span>   struct vlr_subscr *vsub = response->vsub;</span><br><span>         struct sgs_mme_ctx *mme;</span><br><span>     uint8_t new_id[2 + GSM48_TMSI_LEN];</span><br><span style="color: hsl(0, 100%, 40%);">-     uint8_t *new_id_ptr = new_id;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t *new_id_ptr = NULL;</span><br><span>  int new_id_len = 0;</span><br><span>  uint8_t resp_msg_type;</span><br><span> </span><br><span>@@ -403,8 +403,14 @@</span><br><span>                            .tmsi = vsub->tmsi_new,</span><br><span>                   };</span><br><span>                   new_id_len = osmo_mobile_identity_encode_buf(new_id, sizeof(new_id), &tmsi_mi, false);</span><br><span style="color: hsl(0, 100%, 40%);">-                      if (new_id_len > 0)</span><br><span style="color: hsl(120, 100%, 40%);">+                        if (new_id_len > 0) {</span><br><span>                             new_id_ptr = new_id;</span><br><span style="color: hsl(120, 100%, 40%);">+                  } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                              /* Failure to encode the TMSI is not actually possible here, this is just for paranoia</span><br><span style="color: hsl(120, 100%, 40%);">+                                 * and coverity scan. */</span><br><span style="color: hsl(120, 100%, 40%);">+                              new_id_len = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+                               LOGPFSMSL(vsub->sgs_fsm, DMM, LOGL_ERROR, "Cannot encode TMSI Mobile Identity\n");</span><br><span style="color: hsl(120, 100%, 40%);">+                       }</span><br><span>            }</span><br><span>            resp = gsm29118_create_lu_ack(vsub->imsi, &vsub->sgs.lai, new_id_ptr, new_id_len);</span><br><span>                 sgs_tx(mme->conn, resp);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-msc/+/19098">change 19098</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/c/osmo-msc/+/19098"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-msc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I800c5dca3fdbdedf70a64d9fd5a1bdfd1397f431 </div>
<div style="display:none"> Gerrit-Change-Number: 19098 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>