Skip to content

Commit 72c2154

Browse files
david-marchandkevintraynor
authored andcommitted
cmdline: fix highest bit port list parsing
[ upstream commit f3a07a3 ] pl->map is a uint32_t. Caught by UBSan: ../lib/cmdline/cmdline_parse_portlist.c:27:17: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../lib/cmdline/cmdline_parse_portlist.c:27:17 in Fixes: af75078 ("first public release") Signed-off-by: David Marchand <[email protected]> Acked-by: Bruce Richardson <[email protected]> Reviewed-by: Marat Khalili <[email protected]> Acked-by: Chengwen Feng <[email protected]>
1 parent c28dd1d commit 72c2154

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/cmdline/cmdline_parse_portlist.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include <string.h>
1010
#include <errno.h>
1111

12+
#include <rte_bitops.h>
1213
#include <rte_string_fns.h>
14+
1315
#include "cmdline_parse.h"
1416
#include "cmdline_parse_portlist.h"
1517

@@ -24,7 +26,8 @@ static void
2426
parse_set_list(cmdline_portlist_t *pl, size_t low, size_t high)
2527
{
2628
do {
27-
pl->map |= (1 << low++);
29+
pl->map |= RTE_BIT32(low);
30+
low++;
2831
} while (low <= high);
2932
}
3033

0 commit comments

Comments
 (0)