From e08cdd92a648ea8d9bb6ca405f04c91ca485db3c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 26 Nov 2016 00:01:53 +0100 Subject: [PATCH] ue_context_alloc(): Avoid ue->imsi without NULL termination Change-Id: I152e84206e0b2b80fa79956f5adbbe84ff10b4ab Fixes: Coverity CID 57625 --- src/hnbgw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hnbgw.c b/src/hnbgw.c index acca6431..99849279 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -163,9 +163,10 @@ struct ue_context *ue_context_alloc(struct hnb_context *hnb, const char *imsi, return NULL; ue->hnb = hnb; - if (imsi) + if (imsi) { strncpy(ue->imsi, imsi, sizeof(ue->imsi)); - else + ue->imsi[sizeof(ue->imsi)-1] = '\0'; + } else ue->imsi[0] = '\0'; ue->tmsi = tmsi; ue->context_id = get_next_ue_ctx_id(hnb->gw);