Skip to content

Commit 1a1a19f

Browse files
lpereiraAnas Nashif
authored andcommitted
ieee802154_shell: Only accept channels within expected range
Fixes the following issue: "In expression 1UL << chan - 1U, left shifting by more than 31 bits has undefined behavior. The shift amount, chan - 1U, is 4294967295." Coverity-CID: 167140 Jira: ZEP-2131 Signed-off-by: Leandro Pereira <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 37bbe40 commit 1a1a19f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

subsys/net/ip/l2/ieee802154/ieee802154_shell.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ static inline u32_t parse_channel_set(char *str_set)
122122
}
123123

124124
chan = atoi(p);
125-
channel_set |= BIT(chan - 1);
125+
if (chan > 0 && chan < 32) {
126+
channel_set |= BIT(chan - 1);
127+
}
128+
126129
p = n ? n + 1 : n;
127130
} while (n);
128131

0 commit comments

Comments
 (0)