aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libcommon
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/libcommon
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/libcommon')
-rw-r--r--openbsc/src/libcommon/gsm_subscriber_base.c3
-rw-r--r--openbsc/src/libcommon/gsup_test_client.c3
2 files changed, 3 insertions, 3 deletions
diff --git a/openbsc/src/libcommon/gsm_subscriber_base.c b/openbsc/src/libcommon/gsm_subscriber_base.c
index 1f98cc66c..1ecdee5a5 100644
--- a/openbsc/src/libcommon/gsm_subscriber_base.c
+++ b/openbsc/src/libcommon/gsm_subscriber_base.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
@@ -115,7 +116,7 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_subscriber_group *sgrp,
if (!subscr)
return NULL;
- strncpy(subscr->imsi, imsi, sizeof(subscr->imsi)-1);
+ osmo_strlcpy(subscr->imsi, imsi, sizeof(subscr->imsi));
subscr->group = sgrp;
return subscr;
}
diff --git a/openbsc/src/libcommon/gsup_test_client.c b/openbsc/src/libcommon/gsup_test_client.c
index 861212a64..8be4e7aea 100644
--- a/openbsc/src/libcommon/gsup_test_client.c
+++ b/openbsc/src/libcommon/gsup_test_client.c
@@ -75,8 +75,7 @@ static struct imsi_op *imsi_op_alloc(void *ctx, const char *imsi,
return NULL;
io = talloc_zero(ctx, struct imsi_op);
- strncpy(io->imsi, imsi, sizeof(io->imsi));
- io->imsi[sizeof(io->imsi)-1] = '\0';
+ osmo_strlcpy(io->imsi, imsi, sizeof(io->imsi));
io->type = type;
io->timer.cb = imsi_op_timer_cb;
io->timer.data = io;