Skip to content

Commit

Permalink
Addresssanitizer: Fix buffer overflow in test_bitset_getset
Browse files Browse the repository at this point in the history
Summary:
    ==79284==ERROR: AddressSanitizer: global-buffer-overflow on address
    0x00010d405de8 at pc 0x00010d404f79 bp 0x7ffee27fc5c0 sp 0x7ffee27fc5b8
    READ of size 2 at 0x00010d405de8 thread T0
        #0 0x10d404f78 in test_bitset_getset check_bitmap.c:47
        #1 0x10d40e898 in srunner_run_tagged (libcheck.0.dylib:x86_64+0x4898)
        #2 0x10d404c04 in main check_bitmap.c:90
        #3 0x7fff69fa2014 in start (libdyld.dylib:x86_64+0x1014)
  • Loading branch information
sriganes committed Dec 30, 2018
1 parent cdd2656 commit fc41889
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/data_structure/bitmap/check_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ END_TEST
START_TEST(test_bitset_getset)
{
int i, j;
int cols_size = sizeof(cols)/sizeof(uint16_t);

bitset_init(bs, NCOL1);
for (i = 0, j = 0; i < NCOL1; i++) {
for (i = 0, j = 0; i < NCOL1 && j < cols_size; i++) {
if (i == cols[j]) {
bitset_set(bs, i, 1);
j++;
Expand All @@ -53,7 +54,7 @@ START_TEST(test_bitset_getset)
}
}

for (j=0; j < 4; j++) { /* set these bits back to 0 */
for (j=0; j < cols_size; j++) { /* set these bits back to 0 */
ck_assert_int_eq(bitset_get(bs, cols[j]), 1);
bitset_set(bs, cols[j], 0);
ck_assert_int_eq(bitset_get(bs, cols[j]), 0);
Expand Down

0 comments on commit fc41889

Please sign in to comment.