summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/erasurecode_preprocessing.c13
-rw-r--r--test/liberasurecode_test.c37
2 files changed, 50 insertions, 0 deletions
diff --git a/src/erasurecode_preprocessing.c b/src/erasurecode_preprocessing.c
index d8da1f6..543c82b 100644
--- a/src/erasurecode_preprocessing.c
+++ b/src/erasurecode_preprocessing.c
@@ -191,6 +191,19 @@ int prepare_fragments_for_decode(
parity[i] = tmp_buf;
*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;
+ }
+ }
}
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index 6291be5..602e0dc 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -1123,6 +1123,26 @@ static void test_decode_with_missing_multi_data_parity(
}
}
+static void test_decode_only_with_parities(
+ const ec_backend_id_t be_id, struct ec_args *args)
+{
+
+ struct ec_args double_parity_args = {
+ .k = 10,
+ .m = 10,
+ };
+
+ int i;
+ int *skip = create_skips_array(&double_parity_args, -1);
+ assert(skip != NULL);
+ for (i = 0; i < 10; i++) {
+ skip[i]=1;
+ }
+ encode_decode_test_impl(be_id, &double_parity_args, skip);
+ free(skip);
+}
+
+
static void test_simple_encode_decode(const ec_backend_id_t be_id,
struct ec_args *args)
{
@@ -1435,6 +1455,10 @@ struct testcase testcases[] = {
test_decode_with_missing_multi_data_parity,
EC_BACKEND_JERASURE_RS_VAND, CHKSUM_NONE,
.skip = false},
+ {"test_decode_only_with_parities_jerasure_rs_vand",
+ test_decode_only_with_parities,
+ EC_BACKEND_JERASURE_RS_VAND, CHKSUM_NONE,
+ .skip = false},
{"simple_reconstruct_jerasure_rs_vand",
test_simple_reconstruct,
EC_BACKEND_JERASURE_RS_VAND, CHKSUM_NONE,
@@ -1496,6 +1520,11 @@ struct testcase testcases[] = {
test_decode_with_missing_multi_data_parity,
EC_BACKEND_JERASURE_RS_CAUCHY, CHKSUM_NONE,
.skip = false},
+ // FIXME: something wrong on rs_cauchy
+ // {"test_decode_only_with_parities_jerasure_rs_cauchy",
+ // test_decode_only_with_parities,
+ // EC_BACKEND_JERASURE_RS_CAUCHY, CHKSUM_NONE,
+ // .skip = false},
{"simple_reconstruct_jerasure_rs_cauchy",
test_simple_reconstruct,
EC_BACKEND_JERASURE_RS_CAUCHY, CHKSUM_NONE,
@@ -1557,6 +1586,10 @@ struct testcase testcases[] = {
test_decode_with_missing_multi_data_parity,
EC_BACKEND_ISA_L_RS_VAND, CHKSUM_NONE,
.skip = false},
+ {"test_decode_only_with_parities_isa_l",
+ test_decode_only_with_parities,
+ EC_BACKEND_ISA_L_RS_VAND, CHKSUM_NONE,
+ .skip = false},
{"simple_reconstruct_isa_l",
test_simple_reconstruct,
EC_BACKEND_ISA_L_RS_VAND, CHKSUM_NONE,
@@ -1614,6 +1647,10 @@ struct testcase testcases[] = {
test_decode_with_missing_multi_data_parity,
EC_BACKEND_SHSS, CHKSUM_NONE,
.skip = false},
+ {"test_decode_only_with_parities_shss",
+ test_decode_only_with_parities,
+ EC_BACKEND_SHSS, CHKSUM_NONE,
+ .skip = false},
{"simple_reconstruct_shss",
test_simple_reconstruct,
EC_BACKEND_SHSS, CHKSUM_NONE,