diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2019-01-08 10:40:18 +0100 |
---|---|---|
committer | dexter <pmaier@sysmocom.de> | 2019-01-18 08:21:00 +0000 |
commit | d6ef6f1b9163be659693bb546276ab2f655f9cb9 (patch) | |
tree | 4d39160466f28b5ed1785f5934cc2e3abb31512f /src | |
parent | 64b51eb68bd272b6b1f2cefa2b33e9dd74024d0c (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/gsm/gsm29118.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gsm/gsm29118.c b/src/gsm/gsm29118.c index ca210fbf..56e74738 100644 --- a/src/gsm/gsm29118.c +++ b/src/gsm/gsm29118.c @@ -196,9 +196,14 @@ static int msgb_sgsap_name_put(struct msgb *msg, enum sgsap_iei iei, const char { 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 |