aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-10-12 15:47:05 +0200
committerlaforge <laforge@osmocom.org>2020-10-12 15:09:37 +0000
commit715a612aba23f52bad52732df6880926b46898f7 (patch)
tree9610a6717dc11a491797d2115faef1a7a65e9bb2
parent8ebc1acbaa827a439c7e6724f5456075b9eeb5ea (diff)
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
-rw-r--r--src/vty/command.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index fae925ea..d8649f58 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -3085,7 +3085,7 @@ static unsigned int node_flag_mask(const struct cmd_node *cnode)
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 @@ static const char *cmd_flag_mask(const struct cmd_element *cmd,
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;
}