From 309d7f1e4754ac448d8b098bd36287fa37a77475 Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Mon, 30 Mar 2015 10:55:09 +0900 Subject: Fix invalid metadata handling On the current code, get_fragment_partition might touch the invlid memory area with minus index (that means a invalid header) and it causes segmentation fault. This fixes it to handle the minus index as a EBADHEADER and then no segmentaition fault appeared on the case. --- src/erasurecode_preprocessing.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/erasurecode_preprocessing.c') 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 { -- cgit v1.2.1