subscriber: Address coverity warning and truncate the IMSI

The IMSI can only be 15 characters in length, our define gives
us a length of 17. This means we have place for two NULs. Use
strncpy and make sure it is null-terminated.

Fixes: Coverity CID 1040707
This commit is contained in:
Holger Hans Peter Freyther
2013-12-12 15:28:43 +01:00
parent 7672db33bd
commit a5ddf489e1

View File

@@ -104,7 +104,8 @@ struct gsm_subscriber *subscr_get_or_create(struct gsm_network *net,
if (!subscr)
return NULL;
strcpy(subscr->imsi, imsi);
strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH);
subscr->imsi[GSM_IMSI_LENGTH - 1] = '\0';
subscr->net = net;
return subscr;
}