summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKevin Greenan <kmg@box.com>2015-04-26 16:59:04 -0700
committerKevin Greenan <kmg@box.com>2015-04-27 11:59:21 -0700
commita01b1818c874a65d1d1fb8f11ea441e9d3e18771 (patch)
treee38c2ed6b776d578bc4f381d529aea4098b62ab4 /src
parenta380246762c16ea8eb7dbfccd50d296c3743b39e (diff)
downloadliberasurecode-a01b1818c874a65d1d1fb8f11ea441e9d3e18771.tar.gz
This is the fix for Issue #13:
https://bitbucket.org/tsg-/liberasurecode/issue/13/decode-fails-for-many-cases-when-m-k This fix includes: 1.) Proper buffer allocation for the 'missing_idxs' structure, which was not allocating enough space when k > m. 2.) Checks to use header fields of parity fragments during decode when *no* data fragments are available. 3.) Fixed the unit tests to properly handle the case where k <= m. 4.) Extended the unit test framework to support multiple tests per backend 5.) Added tests for all RS implementations: (4,8), (4,4), (10,10)
Diffstat (limited to 'src')
-rw-r--r--src/erasurecode.c4
-rw-r--r--src/erasurecode_preprocessing.c16
2 files changed, 17 insertions, 3 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c
index 2c6a30b..d9a868c 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -587,7 +587,7 @@ int liberasurecode_decode(int desc,
goto out;
}
- missing_idxs = alloc_and_set_buffer(sizeof(char*) * k, -1);
+ missing_idxs = alloc_and_set_buffer(sizeof(char*) * (k + m), -1);
if (NULL == missing_idxs) {
log_error("Could not allocate missing_idxs buffer!");
goto out;
@@ -771,7 +771,7 @@ int liberasurecode_reconstruct_fragment(int desc,
goto out;
}
- missing_idxs = alloc_and_set_buffer(sizeof(int*) * k, -1);
+ missing_idxs = alloc_and_set_buffer(sizeof(int*) * (k + m), -1);
if (NULL == missing_idxs) {
log_error("Could not allocate missing_idxs buffer!");
goto out;
diff --git a/src/erasurecode_preprocessing.c b/src/erasurecode_preprocessing.c
index d8da1f6..e23b028 100644
--- a/src/erasurecode_preprocessing.c
+++ b/src/erasurecode_preprocessing.c
@@ -119,7 +119,7 @@ int prepare_fragments_for_decode(
unsigned long long missing_bm; /* bitmap form of missing indexes list */
int orig_data_size = -1;
int payload_size = -1;
-
+
missing_bm = convert_list_to_bitmap(missing_idxs);
/*
@@ -192,6 +192,20 @@ int prepare_fragments_for_decode(
*realloc_bm = *realloc_bm | (1 << (k + i));
}
+ /* Need to determine the size of the original data */
+ if (((missing_bm & (1 << (k + i))) == 0) && orig_data_size < 0) {
+ orig_data_size = get_orig_data_size(parity[i]);
+ if (orig_data_size < 0) {
+ log_error("Invalid orig_data_size in fragment header!");
+ return -EBADHEADER;
+ }
+ payload_size = get_fragment_payload_size(parity[i]);
+ if (orig_data_size < 0) {
+ log_error("Invalid fragment_size in fragment header!");
+ return -EBADHEADER;
+ }
+ }
+
}
*orig_size = orig_data_size;