diff options
author | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-04-19 21:28:02 -0700 |
---|---|---|
committer | Kota Tsuyuzaki <bloodeagle40234@gmail.com> | 2015-04-19 21:38:44 -0700 |
commit | c68881cef6eb1a7d3dc7d637ff956ede5dc8450e (patch) | |
tree | efc58bacd6348a01c9185c1b2f32d7af5e8305a4 /src/erasurecode_preprocessing.c | |
parent | a380246762c16ea8eb7dbfccd50d296c3743b39e (diff) | |
download | liberasurecode-fix-decode.tar.gz |
Fix decode only with paritiesfix-decode
When decoding only with parities (e.g. k=10, m=10 and decode with
10 parity fragments and no data fragments), current liberasurecode
will give up to decode with a failure because liberasurecode retrieves
original content length and payload size only from a "DATA" fragment.
This patch allows liberasurecode to retrieve also a parity fragment
(if the available fragments consist of only parity fragments) and then
fixes the bug.
Note that this failure happens only when the number of parity fragments
equals to or more than the number of data fragments. (i.e. m >= k)
Diffstat (limited to 'src/erasurecode_preprocessing.c')
-rw-r--r-- | src/erasurecode_preprocessing.c | 13 |
1 files changed, 13 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; + } + } } |