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
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index e3d5c7d..88be512 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 @@
 	/* 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 @@
 		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 @@
 				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 @@
 				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) {