diff options
author | Tim Burke <tim.burke@gmail.com> | 2021-06-01 23:08:11 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2021-06-28 22:55:19 -0700 |
commit | a7e1ddf685af09c9ad99dc2641067a846d8c88e8 (patch) | |
tree | ff031295689ce72756f52a714a418a2e86dd6469 | |
parent | 9dccbc9ff19694612e02c56289c01e454aff113c (diff) | |
download | liberasurecode-a7e1ddf685af09c9ad99dc2641067a846d8c88e8.tar.gz |
Fix underflow in flat_xor_hd code
Change-Id: I9102f9883e979862557bd33958b2d116795b3169
Closes-Bug: #1726816
-rw-r--r-- | src/builtin/xor_codes/xor_hd_code.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/builtin/xor_codes/xor_hd_code.c b/src/builtin/xor_codes/xor_hd_code.c index 9e41ad1..ae9607a 100644 --- a/src/builtin/xor_codes/xor_hd_code.c +++ b/src/builtin/xor_codes/xor_hd_code.c @@ -155,19 +155,21 @@ static int fragments_needed_three_data(xor_code_t *code_desc, int *missing_data, remove_from_missing_list(data_index, missing_data); - // Include all data elements except for this one - *data_bm |= (code_desc->parity_bms[parity_index-code_desc->k]); - - // Include this parity element if (parity_index > -1) { + // Include this parity element *parity_bm |= (1 << (parity_index-code_desc->k)); + // Include all data elements except for this one + *data_bm |= code_desc->parity_bms[parity_index-code_desc->k]; } else { + // Include both parity elements *parity_bm |= (1 << (contains_2d-code_desc->k)); *parity_bm |= (1 << (contains_3d-code_desc->k)); + // And all other data elements that didn't cancel out + *data_bm |= tmp_parity_bm; } ret = fragments_needed_two_data(code_desc, missing_data, missing_parity, data_bm, parity_bm); - + *data_bm &= ~((unsigned int)1 << data_index); return ret; |