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.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11819 )
Change subject: Use safer functions for IMSI ACL
......................................................................
Use safer functions for IMSI ACL
Avoid explicit memset which confuses coverity, use strnlen() and
osmo_strlcpy() to handle strings.
Change-Id: I73fd54ad3a4ab8be5aff0fee5c722597ad766e9d
Fixes: CID163626
---
M src/gprs/sgsn_vty.c
1 file changed, 8 insertions(+), 6 deletions(-)
Approvals:
Harald Welte: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/gprs/sgsn_vty.c b/src/gprs/sgsn_vty.c
index f57a2b9..601b3c5 100644
--- a/src/gprs/sgsn_vty.c
+++ b/src/gprs/sgsn_vty.c
@@ -634,19 +634,21 @@
"Remove IMSI from ACL\n"
"IMSI of subscriber\n")
{
- char imsi_sanitized[GSM23003_IMSI_MAX_DIGITS+1];
+ char imsi_sanitized[GSM23003_IMSI_MAX_DIGITS + 1] = { '0' };
const char *op = argv[0];
const char *imsi = imsi_sanitized;
+ size_t len = strnlen(argv[1], GSM23003_IMSI_MAX_DIGITS + 1);
int rc;
/* Sanitize IMSI */
- if (strlen(argv[1]) > GSM23003_IMSI_MAX_DIGITS) {
- vty_out(vty, "%% IMSI (%s) too long -- ignored!%s",
- argv[1], VTY_NEWLINE);
+ if (len > GSM23003_IMSI_MAX_DIGITS) {
+ vty_out(vty, "%% IMSI (%s) too long (max %u digits) -- ignored!%s",
+ argv[1], GSM23003_IMSI_MAX_DIGITS, VTY_NEWLINE);
return CMD_WARNING;
}
- memset(imsi_sanitized, '0', sizeof(imsi_sanitized));
- strcpy(imsi_sanitized+GSM23003_IMSI_MAX_DIGITS-strlen(argv[1]),argv[1]);
+
+ osmo_strlcpy(imsi_sanitized + GSM23003_IMSI_MAX_DIGITS - len, argv[1],
+ sizeof(imsi_sanitized) - (GSM23003_IMSI_MAX_DIGITS - len));
if (!strcmp(op, "add"))
rc = sgsn_acl_add(imsi, g_cfg);
--
To view, visit https://gerrit.osmocom.org/11819
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I73fd54ad3a4ab8be5aff0fee5c722597ad766e9d
Gerrit-Change-Number: 11819
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181119/2d38df18/attachment.htm>