Change in libosmocore[master]: vty: Fix left shifting out of range on signed variable

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

laforge gerrit-no-reply at lists.osmocom.org
Mon Oct 12 15:09:37 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20573 )

Change subject: vty: Fix left shifting out of range on signed variable
......................................................................

vty: Fix left shifting out of range on signed variable

Fixes following ASan runtime errors while running vty tests:
src/vty/command.c:3088:27: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
src/vty/command.c:3136:23: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: Ie11ff18d6fd9f6e1e91a51b6156fb6b0b7d3a9a8
---
M src/vty/command.c
1 file changed, 3 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/vty/command.c b/src/vty/command.c
index fae925e..d8649f5 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -3085,7 +3085,7 @@
 				continue;
 			if (cmd->attr & (CMD_ATTR_DEPRECATED | CMD_ATTR_HIDDEN))
 				continue;
-			if (~cmd->usrattr & (1 << f))
+			if (~cmd->usrattr & ((unsigned)1 << f))
 				continue;
 
 			if (cmd->attr & CMD_ATTR_LIB_COMMAND)
@@ -3133,9 +3133,9 @@
 	unsigned int f;
 
 	for (f = 0; f < VTY_CMD_USR_ATTR_NUM; f++) {
-		if (~flag_mask & (1 << f))
+		if (~flag_mask & ((unsigned)1 << f))
 			continue;
-		if (~cmd->usrattr & (1 << f)) {
+		if (~cmd->usrattr & ((unsigned)1 << f)) {
 			*(ptr++) = '.';
 			continue;
 		}

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ie11ff18d6fd9f6e1e91a51b6156fb6b0b7d3a9a8
Gerrit-Change-Number: 20573
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201012/2fd0450b/attachment.htm>


More information about the gerrit-log mailing list