aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs/gprs_gmm.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/gprs/gprs_gmm.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/gprs/gprs_gmm.c')
-rw-r--r--openbsc/src/gprs/gprs_gmm.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index e3d5c7d64..88be5126e 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -42,6 +42,7 @@
#include <osmocom/core/signal.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/utils.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/gsm/apn.h>
#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
@@ -683,11 +684,10 @@ static void extract_subscr_msisdn(struct sgsn_mm_ctx *ctx)
/* Prepend a '+' for international numbers */
if (called.plan == 1 && called.type == 1) {
ctx->msisdn[0] = '+';
- strncpy(&ctx->msisdn[1], called.number,
- sizeof(ctx->msisdn) - 1);
+ osmo_strlcpy(&ctx->msisdn[1], called.number,
+ sizeof(ctx->msisdn));
} else {
- strncpy(&ctx->msisdn[0], called.number,
- sizeof(ctx->msisdn) - 1);
+ osmo_strlcpy(ctx->msisdn, called.number, sizeof(ctx->msisdn));
}
}
@@ -725,7 +725,7 @@ static void extract_subscr_hlr(struct sgsn_mm_ctx *ctx)
return;
}
- strncpy(&ctx->hlr[0], called.number, sizeof(ctx->hlr) - 1);
+ osmo_strlcpy(ctx->hlr, called.number, sizeof(ctx->hlr));
}
#ifdef BUILD_IU
@@ -1034,10 +1034,10 @@ static int gsm48_rx_gmm_id_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg)
mm_ctx_cleanup_free(ictx, "GPRS IMSI re-use");
}
}
- strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1);
+ osmo_strlcpy(ctx->imsi, mi_string, sizeof(ctx->imsi));
break;
case GSM_MI_TYPE_IMEI:
- strncpy(ctx->imei, mi_string, sizeof(ctx->imei) - 1);
+ osmo_strlcpy(ctx->imei, mi_string, sizeof(ctx->imei));
break;
case GSM_MI_TYPE_IMEISV:
break;
@@ -1138,7 +1138,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
reject_cause = GMM_CAUSE_NET_FAIL;
goto rejected;
}
- strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1);
+ osmo_strlcpy(ctx->imsi, mi_string, sizeof(ctx->imsi));
#endif
}
if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {