Change in osmo-bts[master]: vty.c: avoid coverity BAD_SHIFT 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/.

osmith gerrit-no-reply at lists.osmocom.org
Fri Oct 18 08:09:40 UTC 2019


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/15806 )


Change subject: vty.c: avoid coverity BAD_SHIFT issues
......................................................................

vty.c: avoid coverity BAD_SHIFT issues

Make it obvious for compilers and for coverity, that the sapi value used
to shift a bit for the sapi_mask is always <= 31. The sapi value is an
index of the value string l1sap_common_sapi_names, which has 24 entries.

Fixes: CID#205067, CID#205068
Change-Id: Id8be0ab67479b1f76a4f624bd3a5242e4fe59f4b
---
M src/common/vty.c
1 file changed, 6 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/06/15806/1

diff --git a/src/common/vty.c b/src/common/vty.c
index 7c043e1..a202507 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -1615,7 +1615,10 @@
 	if (!*sapi_mask)
 		*sapi_mask = talloc(tgt, uint16_t);
 
-	**sapi_mask |= (1 << sapi);
+	if (sapi <= 31)
+		**sapi_mask |= (1 << sapi);
+	else
+		LOGP(DL1P, LOGL_ERROR, "failed to set logging filter for L1 SAPI, can't shift by %i\n", sapi);
 	tgt->filter_map |= (1 << LOG_FLT_L1_SAPI);
 
 	return CMD_SUCCESS;
@@ -1633,7 +1636,8 @@
 		return CMD_SUCCESS;
 
 	sapi_mask = (uint16_t *)tgt->filter_data[LOG_FLT_L1_SAPI];
-	*sapi_mask &= ~(1 << sapi);
+	if (sapi <= 31) /* avoid coverity BAD_SHIFT */
+		*sapi_mask &= ~(1 << sapi);
 
 	return CMD_SUCCESS;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/15806
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Id8be0ab67479b1f76a4f624bd3a5242e4fe59f4b
Gerrit-Change-Number: 15806
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191018/7cbe7135/attachment.htm>


More information about the gerrit-log mailing list