Skip to content

Commit fec47bb

Browse files
iii-iborkmann
authored andcommitted
selftests/bpf: Fix endianness issue in test_sockopt_sk
getsetsockopt() calls getsockopt() with optlen == 1, but then checks the resulting int. It is ok on little endian, but not on big endian. Fix by checking char instead. Fixes: 8a027dc ("selftests/bpf: add sockopt test that exercises sk helpers") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/20200915113928.3768496-1-iii@linux.ibm.com
1 parent b6ed6cf commit fec47bb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎tools/testing/selftests/bpf/prog_tests/sockopt_sk.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ static int getsetsockopt(void)
4545
goto err;
4646
}
4747

48-
if (*(int *)big_buf != 0x08) {
48+
if (*big_buf != 0x08) {
4949
log_err("Unexpected getsockopt(IP_TOS) optval 0x%x != 0x08",
50-
*(int *)big_buf);
50+
(int)*big_buf);
5151
goto err;
5252
}
5353

0 commit comments

Comments
 (0)