aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/gsm_04_08.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-01-13 03:12:08 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-23 11:59:01 +0000
commit93bafb611a58293e0353320a14db298133c9d99a (patch)
tree4ba6d276b7f5e2fda43f21b765d7cca8c6b00d5e /openbsc/src/libmsc/gsm_04_08.c
parent59504dc80fe8c0d9a18994d82586a550c7efa341 (diff)
cosmetic: use osmo_strlcpy() everywhere
Shorten some code and make obvious to the reader that the string copy is done in a safe way. Change-Id: I900726cf06d34128db22a3d3d911ee0d1423b1bd
Diffstat (limited to 'openbsc/src/libmsc/gsm_04_08.c')
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index 34492bbea..742f803d4 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -65,6 +65,7 @@
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
#include <osmocom/gsm/tlv.h>
#include <assert.h>
@@ -1973,10 +1974,9 @@ static int gsm48_cc_rx_setup(struct gsm_trans *trans, struct msgb *msg)
/* use subscriber as calling party number */
setup.fields |= MNCC_F_CALLING;
- strncpy(setup.calling.number, trans->subscr->extension,
- sizeof(setup.calling.number)-1);
- strncpy(setup.imsi, trans->subscr->imsi,
- sizeof(setup.imsi)-1);
+ osmo_strlcpy(setup.calling.number, trans->subscr->extension,
+ sizeof(setup.calling.number));
+ osmo_strlcpy(setup.imsi, trans->subscr->imsi, sizeof(setup.imsi));
/* bearer capability */
if (TLVP_PRESENT(&tp, GSM48_IE_BEARER_CAP)) {
@@ -2153,8 +2153,8 @@ static int gsm48_cc_rx_call_conf(struct gsm_trans *trans, struct msgb *msg)
}
/* IMSI of called subscriber */
- strncpy(call_conf.imsi, trans->subscr->imsi,
- sizeof(call_conf.imsi)-1);
+ osmo_strlcpy(call_conf.imsi, trans->subscr->imsi,
+ sizeof(call_conf.imsi));
new_cc_state(trans, GSM_CSTATE_MO_TERM_CALL_CONF);
@@ -2307,10 +2307,9 @@ static int gsm48_cc_rx_connect(struct gsm_trans *trans, struct msgb *msg)
tlv_parse(&tp, &gsm48_att_tlvdef, gh->data, payload_len, 0, 0);
/* use subscriber as connected party number */
connect.fields |= MNCC_F_CONNECTED;
- strncpy(connect.connected.number, trans->subscr->extension,
- sizeof(connect.connected.number)-1);
- strncpy(connect.imsi, trans->subscr->imsi,
- sizeof(connect.imsi)-1);
+ osmo_strlcpy(connect.connected.number, trans->subscr->extension,
+ sizeof(connect.connected.number));
+ osmo_strlcpy(connect.imsi, trans->subscr->imsi, sizeof(connect.imsi));
/* facility */
if (TLVP_PRESENT(&tp, GSM48_IE_FACILITY)) {