[MERGED] osmocom-bb[master]: mobile/gsm480_ss.c: use secure gsm_7bit_(en|de)code_n_ussd

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Nov 5 19:30:50 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: mobile/gsm480_ss.c: use secure gsm_7bit_(en|de)code_n_ussd
......................................................................


mobile/gsm480_ss.c: use secure gsm_7bit_(en|de)code_n_ussd

Since some 'gsm_7bit_*' functions were deprecated and replaced by
more secure ones with the '_n_' suffix in names, it's better to
use the updated functions.

Change-Id: If8a1983592f5800e3981f29962eb333ac9473f40
---
M src/host/layer23/src/mobile/gsm480_ss.c
1 file changed, 2 insertions(+), 6 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/host/layer23/src/mobile/gsm480_ss.c b/src/host/layer23/src/mobile/gsm480_ss.c
index 8d025e9..ff90faa 100644
--- a/src/host/layer23/src/mobile/gsm480_ss.c
+++ b/src/host/layer23/src/mobile/gsm480_ss.c
@@ -532,7 +532,7 @@
 	}
 
 	/* Encode service request */
-	length = gsm_7bit_encode(msg->data, text);
+	gsm_7bit_encode_n_ussd(msg->data, msgb_tailroom(msg), text, &length);
 	msgb_put(msg, length);
 
 	/* Then wrap it as an Octet String */
@@ -772,11 +772,7 @@
 		return -EINVAL;
 	}
 	num_chars = tag_len * 8 / 7;
-	/* Prevent a mobile-originated buffer-overrun! */
-	if (num_chars > sizeof(text) - 1)
-		num_chars = sizeof(text) - 1;
-	text[sizeof(text) - 1] = '\0';
-	gsm_7bit_decode(text, tag_data, num_chars);
+	gsm_7bit_decode_n_ussd(text, sizeof(text), tag_data, num_chars);
 
 	for (i = 0; text[i]; i++) {
 		if (text[i] == '\r')

-- 
To view, visit https://gerrit.osmocom.org/4641
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If8a1983592f5800e3981f29962eb333ac9473f40
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list