<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/13471">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">common/oml.c: fix: properly push abis_nm_ipa_magic<br><br>In oml_send_msg() we optionally push the A-bis IPA magic string<br>("com.ipaccess") to a given message buffer as LV (Length Value),<br>including the terminating null byte ('\0').<br><br>There was a mix of both sizeof() and strlen() calls, and worse<br>luck, memcpy() has been used in a wrong way, skipping the '\0':<br><br>  memcpy(dest, src, strlen(src));<br><br>In general, this is not critical because the headroom of a given<br>message buffer would most likely be zero-initialized, so the '\0'<br>is already there. However, msgb_push() gives no such guarantee.<br><br>Let's use the libosmocore's TLV API (in particular, lv_put()),<br>and stick to sizeof(), so the null byte will always be included.<br><br>Change-Id: I0c7f8776d0caec40f9ed992db541f43b732e47ae<br>Closes: OS#3022<br>---<br>M src/common/oml.c<br>1 file changed, 3 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/common/oml.c b/src/common/oml.c</span><br><span>index c96a893..80d424f 100644</span><br><span>--- a/src/common/oml.c</span><br><span>+++ b/src/common/oml.c</span><br><span>@@ -36,6 +36,7 @@</span><br><span> #include <osmocom/core/msgb.h></span><br><span> #include <osmocom/gsm/protocol/gsm_12_21.h></span><br><span> #include <osmocom/gsm/abis_nm.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/tlv.h></span><br><span> #include <osmocom/abis/e1_input.h></span><br><span> #include <osmocom/abis/ipaccess.h></span><br><span> </span><br><span>@@ -94,9 +95,8 @@</span><br><span> </span><br><span>       if (is_manuf) {</span><br><span>              /* length byte, string + 0 termination */</span><br><span style="color: hsl(0, 100%, 40%);">-               uint8_t *manuf = msgb_push(msg, 1 + sizeof(abis_nm_ipa_magic));</span><br><span style="color: hsl(0, 100%, 40%);">-         manuf[0] = strlen(abis_nm_ipa_magic)+1;</span><br><span style="color: hsl(0, 100%, 40%);">-         memcpy(manuf+1, abis_nm_ipa_magic, strlen(abis_nm_ipa_magic));</span><br><span style="color: hsl(120, 100%, 40%);">+                uint8_t *manuf = msgb_push(msg, LV_GROSS_LEN(sizeof(abis_nm_ipa_magic)));</span><br><span style="color: hsl(120, 100%, 40%);">+             lv_put(manuf, sizeof(abis_nm_ipa_magic), (const uint8_t *) abis_nm_ipa_magic);</span><br><span>       }</span><br><span> </span><br><span>        /* Push the main OML header and send it off */</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13471">change 13471</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/13471"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bts </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I0c7f8776d0caec40f9ed992db541f43b732e47ae </div>
<div style="display:none"> Gerrit-Change-Number: 13471 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>