Skip to content

Commit 19e3c3f

Browse files
committed
selftests/bpf: Fix parse_int() on 32-bit
Several failures running test_progs relate to parsing int stings: tester_init:PASS:tester_log_buf 0 nsec process_subtest:PASS:obj_open_mem 0 nsec process_subtest:PASS:specs_alloc 0 nsec parse_int:FAIL:281 failed to parse __retval from '0xFFFFff23' process_subtest:FAIL:1153 Can't parse test spec for program 'mov32sx_s16' torvalds#532 verifier_movsx:FAIL These occur because strtol() used by parse_int() will overflow on 32-bit with typical values like '0xd495cdc0'. Fix by using strtoll() instead. Fixes: 19a8e06 ("selftests/bpf: Tests execution support for test_loader.c") Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>
1 parent c1e9b30 commit 19e3c3f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/testing/selftests/bpf/test_loader.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ static int push_disasm_msg(const char *regex_str, bool *on_next_line, struct exp
273273
static int parse_int(const char *str, int *val, const char *name)
274274
{
275275
char *end;
276-
long tmp;
276+
long long tmp;
277277

278278
errno = 0;
279279
if (str_has_pfx(str, "0x"))
280-
tmp = strtol(str + 2, &end, 16);
280+
tmp = strtoll(str + 2, &end, 16);
281281
else
282-
tmp = strtol(str, &end, 10);
282+
tmp = strtoll(str, &end, 10);
283283
if (errno || end[0] != '\0') {
284284
PRINT_FAIL("failed to parse %s from '%s'\n", name, str);
285285
return -EINVAL;

0 commit comments

Comments
 (0)