Change in libosmocore[master]: gsm29118: fix coverity issues

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/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Jan 14 08:07:59 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/12550


Change subject: gsm29118: fix coverity issues
......................................................................

gsm29118: fix coverity issues

The function msgb_sgsap_name_put() assignes the return code of
osmo_apn_from_str() directly to len. Len is an uint8_t and the return
code an int. If osmo_apn_from_str() returns -1. Len would become 0xFF
causing a buffer overrun with msgb_tlv_put. Lets use the proper type to
catch the return code and check it before using it as length.

Change-Id: Ic0bc5114eee47bdcf2300a6e4b0df473d3d1903a
Fixes: CID#190405
Fixes: CID#190401
Related: OS#3615
---
M src/gsm/gsm29118.c
1 file changed, 6 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/50/12550/1

diff --git a/src/gsm/gsm29118.c b/src/gsm/gsm29118.c
index ca210fb..56e7473 100644
--- a/src/gsm/gsm29118.c
+++ b/src/gsm/gsm29118.c
@@ -196,9 +196,14 @@
 {
 	uint8_t buf[APN_MAXLEN];
 	uint8_t len;
+	int rc;
+
 	/* encoding is like DNS names, which is like APN fields */
 	memset(buf, 0, sizeof(buf));
-	len = osmo_apn_from_str(buf, sizeof(buf), name);
+	rc = osmo_apn_from_str(buf, sizeof(buf), name);
+	if (rc < 0)
+		return -1;
+	len = (uint8_t)rc;
 
 	/* Note: While the VLR-Name (see 3GPP TS 29.118, chapter 9.4.22) has
 	 * a flexible length, the MME-Name has a fixed size of 55 octets. (see

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0bc5114eee47bdcf2300a6e4b0df473d3d1903a
Gerrit-Change-Number: 12550
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190114/1426e50d/attachment.htm>


More information about the gerrit-log mailing list