<p>Stefan Sperling has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11782">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">unlink socket path correctly in rf_create_socket()<br><br>In commit 65c62e50335b500ac9e4658530ca5a1b4f5328d8 a call<br>to unlink() was erroneously moved up. Since then unlink()<br>has been called with an uninitialized path variable. The<br>problem went unnoticed because the return value of unlink()<br>was never checked.<br><br>Ensure that unlink() is called with an initialized argument.<br>Also check for success of the unlink operation so that this<br>type of problem will get spotted at run-time in the future.<br><br>Related: CID#188836<br>Change-Id: Ia0c873da305cbb47aef0562f61ec21057363f294<br>Fixes: 65c62e50335b500ac9e4658530ca5a1b4f5328d8<br>---<br>M src/osmo-bsc/bsc_rf_ctrl.c<br>1 file changed, 4 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/82/11782/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/bsc_rf_ctrl.c b/src/osmo-bsc/bsc_rf_ctrl.c</span><br><span>index ac87fb9..34275b9 100644</span><br><span>--- a/src/osmo-bsc/bsc_rf_ctrl.c</span><br><span>+++ b/src/osmo-bsc/bsc_rf_ctrl.c</span><br><span>@@ -450,12 +450,15 @@</span><br><span>  }</span><br><span> </span><br><span>        local.sun_family = AF_UNIX;</span><br><span style="color: hsl(0, 100%, 40%);">-     unlink(local.sun_path);</span><br><span>      if (osmo_strlcpy(local.sun_path, path, sizeof(local.sun_path)) >= sizeof(local.sun_path)) {</span><br><span>               LOGP(DLINP, LOGL_ERROR, "Socket path exceeds maximum length of %zd bytes: %s\n",</span><br><span>                sizeof(local.sun_path), path);</span><br><span>          return -1;</span><br><span>   }</span><br><span style="color: hsl(120, 100%, 40%);">+     if (unlink(local.sun_path) < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+          LOGP(DLINP, LOGL_ERROR, "Could not unlink socket path %s:\n", path);</span><br><span style="color: hsl(120, 100%, 40%);">+                return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span> </span><br><span>        /* we use the same magic that X11 uses in Xtranssock.c for</span><br><span>    * calculating the proper length of the sockaddr */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11782">change 11782</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/11782"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ia0c873da305cbb47aef0562f61ec21057363f294 </div>
<div style="display:none"> Gerrit-Change-Number: 11782 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Stefan Sperling <ssperling@sysmocom.de> </div>