From 6507f6b3f491dcd14cc97295b36bdff47e8b4d9f Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Thu, 11 Feb 2016 20:33:12 -0800 Subject: Fix segmentation fault if frag header corrupted If the fragment header corrupted (I didn't dig it though), it will cause segmentation error which can not be handled in decoding process. To prevent such an unfortunate situation, this patch makes liberasurecode to skip the decoding and to return an error status. --- src/erasurecode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/erasurecode.c b/src/erasurecode.c index 2d6d293..7f47149 100644 --- a/src/erasurecode.c +++ b/src/erasurecode.c @@ -581,6 +581,14 @@ int liberasurecode_decode(int desc, /* We were able to get the original data without decoding! */ goto out; } + if (ret == -EBADHEADER){ + /* currently, if the header of incomming fragments data corrupted, + * it may cause segmentaion fault during decoding process. + * Though, it might be good to determine if we can decode (or not) from + * the fragments but, for now, skip to decode and raise an error for this + * for safety */ + goto out; + } } /* -- cgit v1.2.1