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
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;
}