<p>Stefan Sperling has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11048">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">check for overlong unix socket paths<br><br>In pcu_l1if_open(), use osmo_strlcpy() instead of strncpy() and check for<br>overflow. This catches overlong and non-NUL-terminated socket paths.<br><br>Change-Id: I825190cbb34d052b797e9fb5208884d6f5992839<br>Related: OS#2673<br>---<br>M src/osmobts_sock.cpp<br>1 file changed, 5 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/48/11048/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp</span><br><span>index 477521d..6b49347 100644</span><br><span>--- a/src/osmobts_sock.cpp</span><br><span>+++ b/src/osmobts_sock.cpp</span><br><span>@@ -265,8 +265,11 @@</span><br><span>    }</span><br><span> </span><br><span>        local.sun_family = AF_UNIX;</span><br><span style="color: hsl(0, 100%, 40%);">-     strncpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path));</span><br><span style="color: hsl(0, 100%, 40%);">- local.sun_path[sizeof(local.sun_path) - 1] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+    if (osmo_strlcpy(local.sun_path, bts->pcu_sock_path, sizeof(local.sun_path)) >= sizeof(local.sun_path)) {</span><br><span style="color: hsl(120, 100%, 40%);">+               LOGP(DLGLOBAL, LOGL_ERROR, "Socket path exceeds maximum length of %zd bytes: %s\n",</span><br><span style="color: hsl(120, 100%, 40%);">+              sizeof(local.sun_path), bts->pcu_sock_path);</span><br><span style="color: hsl(120, 100%, 40%);">+          return -ENOSPC;</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/11048">change 11048</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/11048"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I825190cbb34d052b797e9fb5208884d6f5992839 </div>
<div style="display:none"> Gerrit-Change-Number: 11048 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Stefan Sperling <ssperling@sysmocom.de> </div>