From ab44dc40429dfde7c43fa2fdd09ddc3f9a2b8e37 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Fri, 28 Sep 2018 08:44:45 +0200 Subject: [PATCH] return -1 if location is before data --- bose_chaudhuri_hocquenghem_decoder.hh | 6 ++++++ reed_solomon_decoder.hh | 3 +++ 2 files changed, 9 insertions(+) diff --git a/bose_chaudhuri_hocquenghem_decoder.hh b/bose_chaudhuri_hocquenghem_decoder.hh index 6a53b67..1be82cc 100644 --- a/bose_chaudhuri_hocquenghem_decoder.hh +++ b/bose_chaudhuri_hocquenghem_decoder.hh @@ -77,6 +77,9 @@ public: int count = algorithm(syndromes, locations, magnitudes, reinterpret_cast(erasures), erasures_count); if (count <= 0) return count; + for (int i = 0; i < count; ++i) + if ((int)locations[i] < K - data_len) + return -1; for (int i = 0; i < count; ++i) if (1 < (int)magnitudes[i]) return -1; @@ -156,6 +159,9 @@ public: int count = algorithm(syndromes, locations, magnitudes, erasures, erasures_count); if (count <= 0) return count; + for (int i = 0; i < count; ++i) + if ((int)locations[i] < K - data_len) + return -1; for (int i = 0; i < count; ++i) if (1 < (int)magnitudes[i]) return -1; diff --git a/reed_solomon_decoder.hh b/reed_solomon_decoder.hh index d33c5dd..c6445cf 100644 --- a/reed_solomon_decoder.hh +++ b/reed_solomon_decoder.hh @@ -72,6 +72,9 @@ public: int count = algorithm(syndromes, locations, magnitudes, erasures, erasures_count); if (count <= 0) return count; + for (int i = 0; i < count; ++i) + if ((int)locations[i] < K - data_len) + return -1; for (int i = 0; i < count; ++i) { int idx = (int)locations[i] + data_len - K; if (idx < data_len)