<p>Harald Welte has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/10303">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">handover_fsm.c: Fix -Werror=format-security errors<br><br>When building with -Werror=format-security, such as our OBS builds,<br>it fails like this:<br><br>[  118s] handover_fsm.c: In function 'parse_ho_request':<br>[  118s] handover_fsm.c:478:4: error: format not a string literal and no format arguments [-Werror=format-security]<br>[  118s]     gsm0808_cell_id_name(&req->cell_id_serving));<br>[  118s]     ^~~~~~~~~~~~~~~~~~~~<br>[  118s] handover_fsm.c:489:4: error: format not a string literal and no format arguments [-Werror=format-security]<br>[  118s]     gsm0808_cell_id_name(&req->cell_id_target));<br>[  118s]     ^~~~~~~~~~~~~~~~~~~~<br>[  120s] cc1: some warnings being treated as errors<br><br>Let's make sure we don't call sprintf() and friends without a format<br>string.  In fact, if we only want to copy a string without extra<br>formatting, use osmo_strlcpy() or OSMO_STRLCPY_ARRAY().<br><br>Change-Id: I56cff3618f012f6b019f4fca7e2768814487137a<br>---<br>M src/osmo-bsc/handover_fsm.c<br>1 file changed, 2 insertions(+), 4 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/03/10303/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c</span><br><span>index ec2a53d..c2f5c8b 100644</span><br><span>--- a/src/osmo-bsc/handover_fsm.c</span><br><span>+++ b/src/osmo-bsc/handover_fsm.c</span><br><span>@@ -474,8 +474,7 @@</span><br><span>       }</span><br><span>    /* LOG_HO() also calls gsm0808_cell_id_name(), so to be able to use gsm0808_cell_id_name() in</span><br><span>         * logging without getting mixed up with those static buffers, store the result. */</span><br><span style="color: hsl(0, 100%, 40%);">-     snprintf(req->cell_id_serving_name, sizeof(req->cell_id_serving_name),</span><br><span style="color: hsl(0, 100%, 40%);">-             gsm0808_cell_id_name(&req->cell_id_serving));</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_STRLCPY_ARRAY(req->cell_id_serving_name, gsm0808_cell_id_name(&req->cell_id_serving));</span><br><span> </span><br><span>    if (!(e = TLVP_GET(tp2, GSM0808_IE_CELL_IDENTIFIER))) {</span><br><span>              LOG_HO(conn, LOGL_ERROR, "Missing IE: Cell Identifier (Target)\n");</span><br><span>@@ -485,8 +484,7 @@</span><br><span>          LOG_HO(conn, LOGL_ERROR, "Invalid IE: Cell Identifier (Target)\n");</span><br><span>                return false;</span><br><span>        }</span><br><span style="color: hsl(0, 100%, 40%);">-       snprintf(req->cell_id_target_name, sizeof(req->cell_id_target_name),</span><br><span style="color: hsl(0, 100%, 40%);">-               gsm0808_cell_id_name(&req->cell_id_target));</span><br><span style="color: hsl(120, 100%, 40%);">+  OSMO_STRLCPY_ARRAY(req->cell_id_target_name, gsm0808_cell_id_name(&req->cell_id_target));</span><br><span> </span><br><span>      if ((e = TLVP_GET(tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE))) {</span><br><span>          int timeslot;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/10303">change 10303</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/10303"/><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: I56cff3618f012f6b019f4fca7e2768814487137a </div>
<div style="display:none"> Gerrit-Change-Number: 10303 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>