summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/erasurecode.c5
-rw-r--r--src/erasurecode_preprocessing.c3
-rw-r--r--test/liberasurecode_test.c6
3 files changed, 10 insertions, 4 deletions
diff --git a/src/erasurecode.c b/src/erasurecode.c
index 1544ab7..2c6a30b 100644
--- a/src/erasurecode.c
+++ b/src/erasurecode.c
@@ -566,10 +566,7 @@ int liberasurecode_decode(int desc,
available_fragments, num_fragments,
out_data, out_data_len);
- if (ret == -1) {
- /* Ignore - not necessarily an error
- * (see fragments_to_string() in src/erasurecode_preprocessing.c) */
- } else if (ret <= 0) {
+ if (ret == 0) {
/* We were able to get the original data without decoding! */
goto out;
}
diff --git a/src/erasurecode_preprocessing.c b/src/erasurecode_preprocessing.c
index a9a7b55..d8da1f6 100644
--- a/src/erasurecode_preprocessing.c
+++ b/src/erasurecode_preprocessing.c
@@ -224,6 +224,9 @@ int get_fragment_partition(
*/
for (i = 0; i < num_fragments; i++) {
index = get_fragment_idx(fragments[i]);
+ if (index < 0){
+ return -EBADHEADER;
+ }
if (index < k) {
data[index] = fragments[i];
} else {
diff --git a/test/liberasurecode_test.c b/test/liberasurecode_test.c
index dc112f9..548d070 100644
--- a/test/liberasurecode_test.c
+++ b/test/liberasurecode_test.c
@@ -434,6 +434,12 @@ static void test_decode_invalid_args()
rc = liberasurecode_decode(desc, avail_frags, num_avail_frags,
strlen(fake_data), 1,
&decoded_data, &decoded_data_len);
+ // force_metadata_checks results in EINSUFFFRAGS
+ assert(rc == -EINSUFFFRAGS);
+
+ rc = liberasurecode_decode(desc, avail_frags, num_avail_frags,
+ strlen(fake_data), 0,
+ &decoded_data, &decoded_data_len);
assert(rc == -EBADHEADER);
// test with num_fragments < (k)