Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Compress/Rar5Decoder.cpp')
-rw-r--r--CPP/7zip/Compress/Rar5Decoder.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/CPP/7zip/Compress/Rar5Decoder.cpp b/CPP/7zip/Compress/Rar5Decoder.cpp
index 64cce79b..e6c3e467 100644
--- a/CPP/7zip/Compress/Rar5Decoder.cpp
+++ b/CPP/7zip/Compress/Rar5Decoder.cpp
@@ -421,7 +421,7 @@ HRESULT CDecoder::ReadTables(CBitDecoder &_bitStream)
Byte lens[kTablesSizesSum];
unsigned i = 0;
- while (i < kTablesSizesSum)
+ do
{
if (_bitStream._buf >= _bitStream._bufCheck2)
{
@@ -439,34 +439,24 @@ HRESULT CDecoder::ReadTables(CBitDecoder &_bitStream)
return S_FALSE;
else
{
- sym -= 16;
- unsigned sh = ((sym & 1) << 2);
- unsigned num = (unsigned)_bitStream.ReadBits9(3 + sh) + 3 + (sh << 1);
-
+ unsigned num = ((sym - 16) & 1) * 4;
+ num += num + 3 + (unsigned)_bitStream.ReadBits9(num + 3);
num += i;
if (num > kTablesSizesSum)
num = kTablesSizesSum;
-
- if (sym < 2)
+ Byte v = 0;
+ if (sym < 16 + 2)
{
if (i == 0)
- {
- // return S_FALSE;
- continue; // original unRAR
- }
- Byte v = lens[(size_t)i - 1];
- do
- lens[i++] = v;
- while (i < num);
- }
- else
- {
- do
- lens[i++] = 0;
- while (i < num);
+ return S_FALSE;
+ v = lens[(size_t)i - 1];
}
+ do
+ lens[i++] = v;
+ while (i < num);
}
}
+ while (i < kTablesSizesSum);
if (_bitStream.IsBlockOverRead())
return S_FALSE;