mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-10-23 08:12:01 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user