From ad2e18f0c4d7d129aa5fc51c7c3d5fb6f4cfe037 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 10 Dec 2018 15:30:52 +0100 Subject: 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 --- src/gprs/sgsn_libgtp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gprs') diff --git a/src/gprs/sgsn_libgtp.c b/src/gprs/sgsn_libgtp.c index 478d4020c..a8a150280 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 { -- cgit v1.2.3