<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/18597">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">abis_nm: fix: properly truncate feature vector reported by BTS<br><br>The value of the feature vector can not only be greater, but also<br>shorter than size of the buffer! This would potentially result<br>in a buffer overrun. Let's fix this.<br><br>Change-Id: I65e3228022865ea73de2e4821985df3097b9448b<br>---<br>M src/osmo-bsc/abis_nm.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/osmo-bsc refs/changes/97/18597/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/abis_nm.c b/src/osmo-bsc/abis_nm.c</span><br><span>index f600801..db2879f 100644</span><br><span>--- a/src/osmo-bsc/abis_nm.c</span><br><span>+++ b/src/osmo-bsc/abis_nm.c</span><br><span>@@ -571,8 +571,9 @@</span><br><span> </span><br><span>              /* log potential BTS feature vector overflow */</span><br><span>              if (len > sizeof(bts->_features_data)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                  LOGP(DNM, LOGL_NOTICE, "BTS%u Get Attributes Response: feature vector is truncated to %zu bytes\n",</span><br><span style="color: hsl(0, 100%, 40%);">-                        bts->nr, sizeof(bts->_features_data));</span><br><span style="color: hsl(120, 100%, 40%);">+                     LOGP(DNM, LOGL_NOTICE, "BTS%u Get Attributes Response: feature vector is truncated "</span><br><span style="color: hsl(120, 100%, 40%);">+                             "(from %u to %zu bytes)\n", bts->nr, len, sizeof(bts->_features_data));</span><br><span style="color: hsl(120, 100%, 40%);">+                  len = sizeof(bts->_features_data);</span><br><span>                }</span><br><span> </span><br><span>                /* check that max. expected BTS attribute is above given feature vector length */</span><br><span>@@ -583,7 +584,7 @@</span><br><span>                           bts->nr, len);</span><br><span>               }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-           memcpy(bts->_features_data, TLVP_VAL(tp, NM_ATT_MANUF_ID), sizeof(bts->_features_data));</span><br><span style="color: hsl(120, 100%, 40%);">+                memcpy(bts->_features_data, TLVP_VAL(tp, NM_ATT_MANUF_ID), len);</span><br><span> </span><br><span>              for (i = 0; i < _NUM_BTS_FEAT; i++) {</span><br><span>                     if (osmo_bts_has_feature(&bts->features, i) != osmo_bts_has_feature(&bts->model->features, i)) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/18597">change 18597</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/c/osmo-bsc/+/18597"/><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-Change-Id: I65e3228022865ea73de2e4821985df3097b9448b </div>
<div style="display:none"> Gerrit-Change-Number: 18597 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>