From e4abc63e429110aecc0991c78424745f5109fae8 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Fri, 18 Oct 2019 09:59:43 +0200 Subject: 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 --- src/common/vty.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/common/vty.c') diff --git a/src/common/vty.c b/src/common/vty.c index 2e7a66d0..e775d999 100644 --- a/src/common/vty.c +++ b/src/common/vty.c @@ -1616,6 +1616,7 @@ DEFUN(logging_fltr_l1_sapi, logging_fltr_l1_sapi_cmd, "HIDDEN", "HIDDEN") if (!*sapi_mask) *sapi_mask = talloc(tgt, uint16_t); + OSMO_ASSERT(sapi <= 31); **sapi_mask |= (1 << sapi); tgt->filter_map |= (1 << LOG_FLT_L1_SAPI); @@ -1634,6 +1635,7 @@ DEFUN(no_logging_fltr_l1_sapi, no_logging_fltr_l1_sapi_cmd, "HIDDEN", "HIDDEN") if (!tgt->filter_data[LOG_FLT_L1_SAPI]) return CMD_SUCCESS; + OSMO_ASSERT(sapi <= 31); sapi_mask = (uint16_t *)tgt->filter_data[LOG_FLT_L1_SAPI]; *sapi_mask &= ~(1 << sapi); -- cgit v1.2.3