<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13769">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">common/paging.c: fix unaligned pointer access<br><br>Passing a pointer to a packed structure to tmsi_mi_to_uint() may<br>result in unaligned pointer value. Found with clang-8.<br><br>Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777<br>---<br>M src/common/paging.c<br>1 file changed, 22 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/common/paging.c b/src/common/paging.c</span><br><span>index aa604e7..111f947 100644</span><br><span>--- a/src/common/paging.c</span><br><span>+++ b/src/common/paging.c</span><br><span>@@ -302,7 +302,9 @@</span><br><span>                              uint8_t cneed2, const uint8_t *identity3_lv)</span><br><span> {</span><br><span>    struct gsm48_paging2 *pt2 = (struct gsm48_paging2 *) out_buf;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t tmsi;</span><br><span>       uint8_t *cur;</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc;</span><br><span> </span><br><span>  memset(out_buf, 0, sizeof(*pt2));</span><br><span> </span><br><span>@@ -311,8 +313,12 @@</span><br><span>         pt2->pag_mode = GSM48_PM_NORMAL;</span><br><span>  pt2->cneed1 = cneed1;</span><br><span>     pt2->cneed2 = cneed2;</span><br><span style="color: hsl(0, 100%, 40%);">-        tmsi_mi_to_uint(&pt2->tmsi1, tmsi1_lv);</span><br><span style="color: hsl(0, 100%, 40%);">-  tmsi_mi_to_uint(&pt2->tmsi2, tmsi2_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+        rc = tmsi_mi_to_uint(&tmsi, tmsi1_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt2->tmsi1 = tmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = tmsi_mi_to_uint(&tmsi, tmsi2_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt2->tmsi2 = tmsi;</span><br><span>        cur = out_buf + sizeof(*pt2);</span><br><span> </span><br><span>    if (identity3_lv)</span><br><span>@@ -329,6 +335,8 @@</span><br><span>                              const uint8_t *tmsi4_lv, uint8_t cneed4)</span><br><span> {</span><br><span>        struct gsm48_paging3 *pt3 = (struct gsm48_paging3 *) out_buf;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t tmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+        int rc;</span><br><span> </span><br><span>  memset(out_buf, 0, sizeof(*pt3));</span><br><span> </span><br><span>@@ -337,10 +345,18 @@</span><br><span>        pt3->pag_mode = GSM48_PM_NORMAL;</span><br><span>  pt3->cneed1 = cneed1;</span><br><span>     pt3->cneed2 = cneed2;</span><br><span style="color: hsl(0, 100%, 40%);">-        tmsi_mi_to_uint(&pt3->tmsi1, tmsi1_lv);</span><br><span style="color: hsl(0, 100%, 40%);">-  tmsi_mi_to_uint(&pt3->tmsi2, tmsi2_lv);</span><br><span style="color: hsl(0, 100%, 40%);">-  tmsi_mi_to_uint(&pt3->tmsi3, tmsi3_lv);</span><br><span style="color: hsl(0, 100%, 40%);">-  tmsi_mi_to_uint(&pt3->tmsi4, tmsi4_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+        rc = tmsi_mi_to_uint(&tmsi, tmsi1_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt3->tmsi1 = tmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = tmsi_mi_to_uint(&tmsi, tmsi2_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt3->tmsi2 = tmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = tmsi_mi_to_uint(&tmsi, tmsi3_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt3->tmsi3 = tmsi;</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = tmsi_mi_to_uint(&tmsi, tmsi4_lv);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (rc == 0)</span><br><span style="color: hsl(120, 100%, 40%);">+          pt3->tmsi4 = tmsi;</span><br><span> </span><br><span>    /* The structure definition in libosmocore is wrong. It includes as last</span><br><span>      * byte some invalid definition of chneed3/chneed4, so we must do this by hand</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13769">change 13769</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/13769"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ief69854973a098e6da7c05f4417dc11988edd777 </div>
<div style="display:none"> Gerrit-Change-Number: 13769 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Vadim Yanitskiy <axilirator@gmail.com> </div>