summaryrefslogtreecommitdiffstats
path: root/tests/bits/bitrev_test.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-09-20 16:33:50 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-26 00:35:30 +0000
commit4fd6023b0383e7efa3b7b0211104a86ff5d3d4f6 (patch)
tree6f643786bec67b2149264f00eaef7cc86b5a55bb /tests/bits/bitrev_test.c
parente31cf8057f65ec0d8d141eb8f64d5c0e61204f6c (diff)
Fix ASAN failure in bitrev_test
Previously while testing osmo_nibble_shift_left_unal() following error was triggered by AddressSanitizer upon offs == 12 and the last sh_chk line, i.e. shift left of 12 nibbles from in2: ==3890== ERROR: AddressSanitizer: stack-buffer-overflow on address 0xbff5b5b6 at pc 0xb6186862 bp 0xbff5b4a8 sp 0xbff5b49c READ of size 1 at 0xbff5b5b6 thread T0 #0 0xb6186861 (/home/msuraev/source/gsm/libosmocore/src/.libs/libosmocore.so.7.0.0+0xc861) #1 0x8049d8b (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8049d8b) #2 0x804a9d1 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x804a9d1) #3 0xb5fe3af2 (/lib/i386-linux-gnu/libc-2.19.so+0x19af2) #4 0x8048a30 (/home/msuraev/source/gsm/libosmocore/tests/bits/.libs/lt-bitrev_test+0x8048a30) Address 0xbff5b5b6 is located at offset 38 in frame <main> of T0's stack: This frame has 3 object(s): [32, 38) 'in2' [96, 104) 'out' [160, 168) 'in1' The reason is incorrect range in test cycle. Fix it and adjust test output accordingly. Tweaked-by: Neels Hofmeyr <nhofmeyr@sysmocom.de> Fixes: OW#1589 ("undefined behavior in libosmocore triggered by tests") Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
Diffstat (limited to 'tests/bits/bitrev_test.c')
-rw-r--r--tests/bits/bitrev_test.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tests/bits/bitrev_test.c b/tests/bits/bitrev_test.c
index 08f08278..b96241c5 100644
--- a/tests/bits/bitrev_test.c
+++ b/tests/bits/bitrev_test.c
@@ -297,7 +297,9 @@ int main(int argc, char **argv)
sh_chk(in1, ARRAY_SIZE(in1), offs, true);
sh_chk(in1, ARRAY_SIZE(in1), offs, false);
sh_chk(in2, ARRAY_SIZE(in2), offs, true);
- sh_chk(in2, ARRAY_SIZE(in2), offs, false);
+ /* in2 is too short to shift left 12 nibbles */
+ if (offs < 12)
+ sh_chk(in2, ARRAY_SIZE(in2), offs, false);
}
return 0;
}