<p>fixeria <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-pcu/+/14923">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  laforge: Looks good to me, approved
  keith: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">gprs_bssgp_pcu.cpp: check return code of gsm48_mi_to_string()<br><br>Change-Id: Id1ad279ce9bef38eb3d11ac62337276207e8d8bd<br>---<br>M src/gprs_bssgp_pcu.cpp<br>1 file changed, 17 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp</span><br><span>index 3ea3e59..f7c681c 100644</span><br><span>--- a/src/gprs_bssgp_pcu.cpp</span><br><span>+++ b/src/gprs_bssgp_pcu.cpp</span><br><span>@@ -28,6 +28,7 @@</span><br><span> #include <pdch.h></span><br><span> </span><br><span> extern "C" {</span><br><span style="color: hsl(120, 100%, 40%);">+     #include <osmocom/gsm/protocol/gsm_23_003.h></span><br><span>   #include <osmocom/core/utils.h></span><br><span>        #include "coding_scheme.h"</span><br><span> }</span><br><span>@@ -93,6 +94,7 @@</span><br><span>        char imsi[16] = "000";</span><br><span>     uint8_t ms_class = 0;</span><br><span>        uint8_t egprs_ms_class = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+   int rc;</span><br><span> #if 0</span><br><span>     MS_Radio_Access_capability_t rac;</span><br><span> #endif</span><br><span>@@ -120,8 +122,13 @@</span><br><span>    * will listen to all paging blocks. */</span><br><span>      if (TLVP_PRESENT(tp, BSSGP_IE_IMSI))</span><br><span>         {</span><br><span style="color: hsl(0, 100%, 40%);">-               gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI),</span><br><span style="color: hsl(0, 100%, 40%);">-                                                    TLVP_LEN(tp, BSSGP_IE_IMSI));</span><br><span style="color: hsl(120, 100%, 40%);">+          /* gsm48_mi_to_string() returns number of bytes written, including '\0' */</span><br><span style="color: hsl(120, 100%, 40%);">+            rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI),</span><br><span style="color: hsl(120, 100%, 40%);">+                                                          TLVP_LEN(tp, BSSGP_IE_IMSI));</span><br><span style="color: hsl(120, 100%, 40%);">+             if (rc != GSM23003_IMSI_MAX_DIGITS + 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                     LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);</span><br><span style="color: hsl(120, 100%, 40%);">+                 return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg);</span><br><span style="color: hsl(120, 100%, 40%);">+           }</span><br><span>    }</span><br><span> </span><br><span> #if 0 /* Do not rely on this IE. TODO: make this configurable */</span><br><span>@@ -172,6 +179,7 @@</span><br><span>      char imsi[16];</span><br><span>       uint8_t *ptmsi = (uint8_t *) TLVP_VAL(tp, BSSGP_IE_TMSI);</span><br><span>    uint16_t ptmsi_len = TLVP_LEN(tp, BSSGP_IE_TMSI);</span><br><span style="color: hsl(120, 100%, 40%);">+     int rc;</span><br><span> </span><br><span>  LOGP(DBSSGP, LOGL_NOTICE, " P-TMSI = ");</span><br><span>   for (int i = 0; i < ptmsi_len; i++)</span><br><span>@@ -185,7 +193,13 @@</span><br><span>                return -EINVAL;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI), TLVP_LEN(tp, BSSGP_IE_IMSI));</span><br><span style="color: hsl(120, 100%, 40%);">+     /* gsm48_mi_to_string() returns number of bytes written, including '\0' */</span><br><span style="color: hsl(120, 100%, 40%);">+    rc = gsm48_mi_to_string(imsi, sizeof(imsi), TLVP_VAL(tp, BSSGP_IE_IMSI),</span><br><span style="color: hsl(120, 100%, 40%);">+                                                  TLVP_LEN(tp, BSSGP_IE_IMSI));</span><br><span style="color: hsl(120, 100%, 40%);">+     if (rc != GSM23003_IMSI_MAX_DIGITS + 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+             LOGP(DBSSGP, LOGL_NOTICE, "Failed to parse IMSI IE (rc=%d)\n", rc);</span><br><span style="color: hsl(120, 100%, 40%);">+         return bssgp_tx_status(BSSGP_CAUSE_COND_IE_ERR, NULL, msg);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span> </span><br><span>        return gprs_rlcmac_paging_request(ptmsi, ptmsi_len, imsi);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-pcu/+/14923">change 14923</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-pcu/+/14923"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-pcu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id1ad279ce9bef38eb3d11ac62337276207e8d8bd </div>
<div style="display:none"> Gerrit-Change-Number: 14923 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: keith <keith@rhizomatica.org> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>