mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-03 21:43:32 +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)
|
if (!subscr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strcpy(subscr->imsi, imsi);
|
strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH);
|
||||||
|
subscr->imsi[GSM_IMSI_LENGTH - 1] = '\0';
|
||||||
subscr->net = net;
|
subscr->net = net;
|
||||||
return subscr;
|
return subscr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user