<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11217">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">layer23/l1ctl.c: fix: verify msg length using l1h, not l2h<br><br>The actual L1CTL header is pointed by 'msg->l1h', not 'l2h'!<br>Since msg->l2h is NULL (because nobody set it), the result of<br>msgb_l2len() would always be bigger than size of L1CTL header,<br>as it is calculated in the following way:<br><br>  return msgb->tail - (uint8_t *)msgb_l2(msgb);<br><br>So, in case if 'msg->l2h' is NULL, it turns into:<br><br>  return msgb->tail - 0;<br><br>Change-Id: I7fe2e00bb45ba07c9bb7438445eededfa09c96f3<br>---<br>M src/host/layer23/src/common/l1ctl.c<br>1 file changed, 4 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/17/11217/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c</span><br><span>index 9a3bc0e..c8695ca 100644</span><br><span>--- a/src/host/layer23/src/common/l1ctl.c</span><br><span>+++ b/src/host/layer23/src/common/l1ctl.c</span><br><span>@@ -874,9 +874,10 @@</span><br><span>         int rc = 0;</span><br><span>  struct l1ctl_hdr *l1h;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-      if (msgb_l2len(msg) < sizeof(*l1h)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                LOGP(DL1C, LOGL_ERROR, "Short Layer2 message: %u\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                  msgb_l2len(msg));</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Make sure a message has L1CTL header (pointed by msg->l1h) */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (msgb_l1len(msg) < sizeof(*l1h)) {</span><br><span style="color: hsl(120, 100%, 40%);">+              LOGP(DL1C, LOGL_ERROR, "Short L1CTL message, "</span><br><span style="color: hsl(120, 100%, 40%);">+                      "missing the header (len=%u)\n", msgb_l1len(msg));</span><br><span>                 msgb_free(msg);</span><br><span>              return -1;</span><br><span>   }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11217">change 11217</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/11217"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmocom-bb </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I7fe2e00bb45ba07c9bb7438445eededfa09c96f3 </div>
<div style="display:none"> Gerrit-Change-Number: 11217 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>