Change in libosmocore[master]: tests: bitrev_test: Fix dynamic-stack-buffer-overflow

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu May 17 07:12:24 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9205 )

Change subject: tests: bitrev_test: Fix dynamic-stack-buffer-overflow
......................................................................

tests: bitrev_test: Fix dynamic-stack-buffer-overflow

Fixes following AddressSanitizer report:
==1983==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address 0x7ffc245f47e6 at pc 0x7f3e2deea68c bp 0x7ffc245f4750 sp 0x7ffc245f4740
WRITE of size 1 at 0x7ffc245f47e6 thread T0
    #0 0x7f3e2deea68b in osmo_nibble_shift_right libosmocore/src/bits.c:92
    #1 0x55c01902e1ab in sh_chk libosmocore/tests/bits/bitrev_test.c:215
    #2 0x55c01902ed8f in main libosmocore/tests/bits/bitrev_test.c:305
    #3 0x7f3e2c93006a in __libc_start_main (/usr/lib/libc.so.6+0x2306a)
    #4 0x55c01902c059 in _start (libosmocore/tests/bits/.libs/lt-bitrev_test+0x5059)

This patch can be seen as a follow-up of commit
4fd6023b0383e7efa3b7b0211104a86ff5d3d4f6, which already fixed the
left-shift case in the same way.

Change-Id: I6e86d0164b7e982bf7b7449d5b3abfb3e1e5da46
---
M tests/bits/bitrev_test.c
M tests/bits/bitrev_test.ok
2 files changed, 3 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/tests/bits/bitrev_test.c b/tests/bits/bitrev_test.c
index ed3939a..4a3c1b4 100644
--- a/tests/bits/bitrev_test.c
+++ b/tests/bits/bitrev_test.c
@@ -299,10 +299,11 @@
 	for (offs = 0; offs < 13; 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);
 		/* in2 is too short to shift left 12 nibbles */
-		if (offs < 12)
+		if (offs < 12) {
+			sh_chk(in2, ARRAY_SIZE(in2), offs, true);
 			sh_chk(in2, ARRAY_SIZE(in2), offs, false);
+		}
 	}
 	return 0;
 }
diff --git a/tests/bits/bitrev_test.ok b/tests/bits/bitrev_test.ok
index d2fb12c..580fb63 100644
--- a/tests/bits/bitrev_test.ok
+++ b/tests/bits/bitrev_test.ok
@@ -154,5 +154,3 @@
      OUT: 0f00dcafedea
 [8] L IN: f00dcafedeadbeef, nibble 12:
      OUT: 00dcafedeadb
-[6] R IN: b00bbabeface, nibble 12:
-     OUT: 0b00bbabefac

-- 
To view, visit https://gerrit.osmocom.org/9205
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6e86d0164b7e982bf7b7449d5b3abfb3e1e5da46
Gerrit-Change-Number: 9205
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180517/76e62566/attachment.htm>


More information about the gerrit-log mailing list