From 1152362b515444bf236801a87917e9979d468e70 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 1 Aug 2018 18:35:34 +0200 Subject: [PATCH] handover_fsm.c: Fix -Werror=format-security errors When building with -Werror=format-security, such as our OBS builds, it fails like this: [ 118s] handover_fsm.c: In function 'parse_ho_request': [ 118s] handover_fsm.c:478:4: error: format not a string literal and no format arguments [-Werror=format-security] [ 118s] gsm0808_cell_id_name(&req->cell_id_serving)); [ 118s] ^~~~~~~~~~~~~~~~~~~~ [ 118s] handover_fsm.c:489:4: error: format not a string literal and no format arguments [-Werror=format-security] [ 118s] gsm0808_cell_id_name(&req->cell_id_target)); [ 118s] ^~~~~~~~~~~~~~~~~~~~ [ 120s] cc1: some warnings being treated as errors Let's make sure we don't call sprintf() and friends without a format string. In fact, if we only want to copy a string without extra formatting, use osmo_strlcpy() or OSMO_STRLCPY_ARRAY(). Change-Id: I56cff3618f012f6b019f4fca7e2768814487137a --- src/osmo-bsc/handover_fsm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c index ec2a53d2d..c2f5c8bfe 100644 --- a/src/osmo-bsc/handover_fsm.c +++ b/src/osmo-bsc/handover_fsm.c @@ -474,8 +474,7 @@ static bool parse_ho_request(struct gsm_subscriber_connection *conn, const struc } /* LOG_HO() also calls gsm0808_cell_id_name(), so to be able to use gsm0808_cell_id_name() in * logging without getting mixed up with those static buffers, store the result. */ - snprintf(req->cell_id_serving_name, sizeof(req->cell_id_serving_name), - gsm0808_cell_id_name(&req->cell_id_serving)); + OSMO_STRLCPY_ARRAY(req->cell_id_serving_name, gsm0808_cell_id_name(&req->cell_id_serving)); if (!(e = TLVP_GET(tp2, GSM0808_IE_CELL_IDENTIFIER))) { LOG_HO(conn, LOGL_ERROR, "Missing IE: Cell Identifier (Target)\n"); @@ -485,8 +484,7 @@ static bool parse_ho_request(struct gsm_subscriber_connection *conn, const struc LOG_HO(conn, LOGL_ERROR, "Invalid IE: Cell Identifier (Target)\n"); return false; } - snprintf(req->cell_id_target_name, sizeof(req->cell_id_target_name), - gsm0808_cell_id_name(&req->cell_id_target)); + OSMO_STRLCPY_ARRAY(req->cell_id_target_name, gsm0808_cell_id_name(&req->cell_id_target)); if ((e = TLVP_GET(tp, GSM0808_IE_CIRCUIT_IDENTITY_CODE))) { int timeslot;