aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-12-10 15:30:52 +0100
committerMax <msuraev@sysmocom.de>2018-12-10 18:06:08 +0000
commitad2e18f0c4d7d129aa5fc51c7c3d5fb6f4cfe037 (patch)
tree58cc449f3ada09f3f64169d2388a222d6c022635
parent88d149c0b8c43eac37850f180683ce6804ab94ee (diff)
Use explicit length check
Use OSMO_MIN macro to check for MSISDN length. This makes the code cleaner and will, hopefully, aid static analysis tools. Change-Id: Ic0fbeb8d248c74e54bfb51ba2cdea55c4f386ac7 Fixes: CID57879
-rw-r--r--src/gprs/sgsn_libgtp.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/gprs/sgsn_libgtp.c b/src/gprs/sgsn_libgtp.c
index 478d402..a8a1502 100644
--- a/src/gprs/sgsn_libgtp.c
+++ b/src/gprs/sgsn_libgtp.c
@@ -176,9 +176,7 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
/* Put the MSISDN in case we have it */
if (mmctx->subscr && mmctx->subscr->sgsn_data->msisdn_len) {
- pdp->msisdn.l = mmctx->subscr->sgsn_data->msisdn_len;
- if (pdp->msisdn.l > sizeof(pdp->msisdn.v))
- pdp->msisdn.l = sizeof(pdp->msisdn.v);
+ pdp->msisdn.l = OSMO_MIN(mmctx->subscr->sgsn_data->msisdn_len, sizeof(pdp->msisdn.v));
memcpy(pdp->msisdn.v, mmctx->subscr->sgsn_data->msisdn,
pdp->msisdn.l);
} else {