Change in osmo-msc[master]: vlr_access_req_fsm.c: use osmo_strlcpy and avoid compiler error

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Jul 26 18:32:03 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/10182


Change subject: vlr_access_req_fsm.c: use osmo_strlcpy and avoid compiler error
......................................................................

vlr_access_req_fsm.c: use osmo_strlcpy and avoid compiler error

gcc 8.1.0:
../../../../src/osmo-msc/src/libvlr/vlr_access_req_fsm.c:679:3: error: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 31 [-Werror=stringop-truncation]
   strncpy(par->imsi, mi_string, sizeof(par->imsi)-1);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Mobile Identity is a union of various kinds, but the IMSI is at most 15
digits, so truncation is "intended". I hope other layers validate the correct
length of an IMSI MI.

Change-Id: I0a17a188fc91e42e252ae4bf1d6cd0bf0e5eb077
---
M src/libvlr/vlr_access_req_fsm.c
1 file changed, 1 insertion(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/82/10182/1

diff --git a/src/libvlr/vlr_access_req_fsm.c b/src/libvlr/vlr_access_req_fsm.c
index 79eb75f..3a0760d 100644
--- a/src/libvlr/vlr_access_req_fsm.c
+++ b/src/libvlr/vlr_access_req_fsm.c
@@ -676,8 +676,7 @@
 	mi_type = mi_lv[1] & GSM_MI_TYPE_MASK;
 	switch (mi_type) {
 	case GSM_MI_TYPE_IMSI:
-		strncpy(par->imsi, mi_string, sizeof(par->imsi)-1);
-		par->imsi[sizeof(par->imsi)-1] = '\0';
+		osmo_strlcpy(par->imsi, mi_string, sizeof(par->imsi));
 		par->by_tmsi = false;
 		break;
 	case GSM_MI_TYPE_TMSI:

-- 
To view, visit https://gerrit.osmocom.org/10182
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a17a188fc91e42e252ae4bf1d6cd0bf0e5eb077
Gerrit-Change-Number: 10182
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180726/53ff7a58/attachment.htm>


More information about the gerrit-log mailing list