<p>Pau Espin Pedrol has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9510">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bsc-nat: ipaccess_auth_bsc: Close bsc conn immediately on bad format received<br><br>This commit changes behaviour to a (imho) better logic and is a<br>preparation for follow-up commits to avoid heap-use-after-free error<br>when closing the bsc connection.<br><br>Previously, authentication would still not be accepted but the<br>connection would be staying alive for a while until id_timeout timer<br>triggers. Let's close the connection immediately instead, this way BSC<br>side can see quickly something is wrong with what it is sending.<br><br>Furthermore, this way the logic of the function is simplified: If auth<br>goes well, conn is alive. If auth goes wrong, conn is closed.<br><br>Change-Id: I972961b8967076c56c607f98c2360054144951e4<br>---<br>M openbsc/src/osmo-bsc_nat/bsc_nat.c<br>1 file changed, 2 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/10/9510/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c</span><br><span>index 373ba97..fb2ec83 100644</span><br><span>--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c</span><br><span>+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c</span><br><span>@@ -1038,12 +1038,14 @@</span><br><span>       if (len <= 0) {</span><br><span>           LOGP(DNAT, LOGL_ERROR, "Token with length zero on fd: %d\n",</span><br><span>                       bsc->write_queue.bfd.fd);</span><br><span style="color: hsl(120, 100%, 40%);">+          bsc_close_connection(bsc);</span><br><span>           return;</span><br><span>      }</span><br><span> </span><br><span>        if (token[len - 1] != '\0') {</span><br><span>                LOGP(DNAT, LOGL_ERROR, "Token not null terminated on fd: %d\n",</span><br><span>                    bsc->write_queue.bfd.fd);</span><br><span style="color: hsl(120, 100%, 40%);">+          bsc_close_connection(bsc);</span><br><span>           return;</span><br><span>      }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9510">change 9510</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/9510"/><meta itemprop="name" content="View Change"/></div></div>

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