Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: third_party/lzma/v4_65/files/CPP/7zip/Archive/Lzma/LzmaIn.cpp

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Archive/LzmaIn.cpp
2
3 #include "StdAfx.h"
4
5 #include "LzmaIn.h"
6
7 #include "../../Common/StreamUtils.h"
8
9 namespace NArchive {
10 namespace NLzma {
11
12 static bool CheckDictSize(const Byte *p)
13 {
14 UInt32 dicSize = GetUi32(p);
15 int i;
16 for (i = 1; i <= 30; i++)
17 if (dicSize == ((UInt32)2 << i) || dicSize == ((UInt32)3 << i))
18 return true;
19 return false;
20 }
21
22 HRESULT ReadStreamHeader(ISequentialInStream *inStream, CHeader &block)
23 {
24 Byte sig[5 + 9];
25 RINOK(ReadStream_FALSE(inStream, sig, 5 + 8));
26
27 const Byte kMaxProp0Val = 5 * 5 * 9 - 1;
28 if (sig[0] > kMaxProp0Val)
29 return S_FALSE;
30
31 for (int i = 0; i < 5; i++)
32 block.LzmaProps[i] = sig[i];
33
34 block.IsThereFilter = false;
35 block.FilterMethod = 0;
36
37 if (!CheckDictSize(sig + 1))
38 {
39 if (sig[0] > 1 || sig[1] > kMaxProp0Val)
40 return S_FALSE;
41 block.IsThereFilter = true;
42 block.FilterMethod = sig[0];
43 for (int i = 0; i < 5; i++)
44 block.LzmaProps[i] = sig[i + 1];
45 if (!CheckDictSize(block.LzmaProps + 1))
46 return S_FALSE;
47 RINOK(ReadStream_FALSE(inStream, sig + 5 + 8, 1));
48 }
49 UInt32 unpOffset = 5 + (block.IsThereFilter ? 1 : 0);
50 block.UnpackSize = GetUi64(sig + unpOffset);
51 if (block.HasUnpackSize() && block.UnpackSize >= ((UInt64)1 << 56))
52 return S_FALSE;
53 return S_OK;
54 }
55
56 }}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698