[PATCH] libosmocore[master]: Fix ASAN failure in bitrev_test

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Tue Sep 20 16:45:16 UTC 2016


Review at  https://gerrit.osmocom.org/863

Fix ASAN failure in bitrev_test

Previously while testing osmo_nibble_shift_left_unal() following error
was triggered by AddressSanitizer:

==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.

Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
Fixes: OW#1589
---
M tests/bits/bitrev_test.c
M tests/bits/bitrev_test.ok
2 files changed, 1 insertion(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/863/1

diff --git a/tests/bits/bitrev_test.c b/tests/bits/bitrev_test.c
index 08f0827..59f173a 100644
--- a/tests/bits/bitrev_test.c
+++ b/tests/bits/bitrev_test.c
@@ -293,7 +293,7 @@
 	const uint8_t in1[] = { 0xF0, 0x0D, 0xCA, 0xFE, 0xDE, 0xAD, 0xBE, 0xEF },
 		      in2[] = { 0xB0, 0x0B, 0xBA, 0xBE, 0xFA, 0xCE };
 
-	for (offs = 0; offs < 13; offs++) {
+	for (offs = 0; offs < 12; offs++) {
 		sh_chk(in1, ARRAY_SIZE(in1), offs, true);
 		sh_chk(in1, ARRAY_SIZE(in1), offs, false);
 		sh_chk(in2, ARRAY_SIZE(in2), offs, true);
diff --git a/tests/bits/bitrev_test.ok b/tests/bits/bitrev_test.ok
index 9fbb4d9..843a39a 100644
--- a/tests/bits/bitrev_test.ok
+++ b/tests/bits/bitrev_test.ok
@@ -150,11 +150,3 @@
      OUT: 0b00bbabef
 [6] L IN: b00bbabeface, nibble 11:
      OUT: 00bbabefac
-[8] R IN: f00dcafedeadbeef, nibble 12:
-     OUT: 0f00dcafedea
-[8] L IN: f00dcafedeadbeef, nibble 12:
-     OUT: 00dcafedeadb
-[6] R IN: b00bbabeface, nibble 12:
-     OUT: 0b00bbabefac
-[6] L IN: b00bbabeface, nibble 12:
-     OUT: 00bbabeface0

-- 
To view, visit https://gerrit.osmocom.org/863
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5eb3f600290c05b4ab9ac2450a28d616e6b415fd
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list