Skip to content

Commit 7a7b5a5

Browse files
committed
Revert "Update unrar to 7.1.5"
This reverts commit cb7782e. The upgrade is problematic, it will be reviewed and re-attempted later. For now, we want a working next build.
1 parent dee4636 commit 7a7b5a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+302
-1182
lines changed

vendor/unrar/arccmt.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ bool Archive::DoGetComment(std::wstring &CmtData)
3636
{
3737
// Current (RAR 3.0+) version of archive comment.
3838
Seek(GetStartPos(),SEEK_SET);
39-
if (SearchSubBlock(SUBHEAD_TYPE_CMT)!=0)
40-
if (ReadCommentData(CmtData))
41-
return true;
42-
else
43-
uiMsg(UIERROR_CMTBROKEN,FileName);
44-
return false;
39+
return SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData);
4540
}
4641
#ifndef SFX_MODULE
4742
// Old style (RAR 2.9) comment header embedded into the main

vendor/unrar/archive.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ Archive::Archive(CommandData *InitCmd)
2626
FailedHeaderDecryption=false;
2727
BrokenHeader=false;
2828
LastReadBlock=0;
29-
CurHeaderType=HEAD_UNKNOWN;
3029

3130
CurBlockPos=0;
3231
NextBlockPos=0;
3332

34-
RecoveryPercent=-1;
3533

3634
MainHead.Reset();
3735
CryptHead={};
@@ -69,7 +67,7 @@ void Archive::CheckArc(bool EnableBroken)
6967
// password is incorrect.
7068
if (!FailedHeaderDecryption)
7169
uiMsg(UIERROR_BADARCHIVE,FileName);
72-
ErrHandler.Exit(RARX_BADARC);
70+
ErrHandler.Exit(RARX_FATAL);
7371
}
7472
}
7573

@@ -111,11 +109,9 @@ RARFORMAT Archive::IsSignature(const byte *D,size_t Size)
111109
// We check the last signature byte, so we can return a sensible
112110
// warning in case we'll want to change the archive format
113111
// sometimes in the future.
114-
#ifndef SFX_MODULE
115112
if (D[6]==0)
116113
Type=RARFMT15;
117114
else
118-
#endif
119115
if (D[6]==1)
120116
Type=RARFMT50;
121117
else

vendor/unrar/archive.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Archive:public File
4747
bool DummyCmd;
4848
CommandData *Cmd;
4949

50-
int RecoveryPercent;
5150

5251
RarTime LatestTime;
5352
int LastReadBlock;
@@ -59,14 +58,13 @@ class Archive:public File
5958
bool ProhibitQOpen;
6059
#endif
6160
public:
62-
Archive(CommandData *InitCmd=nullptr);
61+
Archive(CommandData *InitCmd=NULL);
6362
~Archive();
6463
static RARFORMAT IsSignature(const byte *D,size_t Size);
6564
bool IsArchive(bool EnableBroken);
6665
size_t SearchBlock(HEADER_TYPE HeaderType);
6766
size_t SearchSubBlock(const wchar *Type);
6867
size_t SearchRR();
69-
int GetRecoveryPercent() {return RecoveryPercent;}
7068
size_t ReadHeader();
7169
void CheckArc(bool EnableBroken);
7270
void CheckOpen(const std::wstring &Name);
@@ -149,9 +147,6 @@ class Archive:public File
149147
bool NewArchive;
150148

151149
std::wstring FirstVolumeName;
152-
#ifdef PROPAGATE_MOTW
153-
MarkOfTheWeb Motw;
154-
#endif
155150
};
156151

157152

vendor/unrar/arcread.cpp

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ size_t Archive::ReadHeader()
2020
case RARFMT14:
2121
ReadSize=ReadHeader14();
2222
break;
23+
#endif
2324
case RARFMT15:
2425
ReadSize=ReadHeader15();
2526
break;
26-
#endif
2727
case RARFMT50:
2828
ReadSize=ReadHeader50();
2929
break;
@@ -106,9 +106,6 @@ void Archive::UnexpEndArcMsg()
106106
if (CurBlockPos!=ArcSize || NextBlockPos!=ArcSize)
107107
{
108108
uiMsg(UIERROR_UNEXPEOF,FileName);
109-
if (CurHeaderType!=HEAD_FILE && CurHeaderType!=HEAD_UNKNOWN)
110-
uiMsg(UIERROR_TRUNCSERVICE,FileName,SubHead.FileName);
111-
112109
ErrHandler.SetErrorCode(RARX_WARNING);
113110
}
114111
}
@@ -140,7 +137,6 @@ inline int64 SafeAdd(int64 v1,int64 v2,int64 f)
140137
}
141138

142139

143-
#ifndef SFX_MODULE
144140
size_t Archive::ReadHeader15()
145141
{
146142
RawRead Raw(this);
@@ -149,7 +145,7 @@ size_t Archive::ReadHeader15()
149145

150146
if (Decrypt)
151147
{
152-
#ifdef RAR_NOCRYPT // For rarext.dll, Setup.SFX and unrar_nocrypt.dll.
148+
#ifdef RAR_NOCRYPT // For rarext.dll and unrar_nocrypt.dll.
153149
return 0;
154150
#else
155151
RequestArcPassword(NULL);
@@ -549,7 +545,6 @@ size_t Archive::ReadHeader15()
549545

550546
return Raw.Size();
551547
}
552-
#endif // #ifndef SFX_MODULE
553548

554549

555550
size_t Archive::ReadHeader50()
@@ -745,15 +740,10 @@ size_t Archive::ReadHeader50()
745740
byte csum[SIZE_PSWCHECK_CSUM];
746741
Raw.GetB(csum,SIZE_PSWCHECK_CSUM);
747742

748-
// Exclude this code for rarext.dll, Setup.SFX and unrar_nocrypt.dll linked
749-
// without sha256. But still set Encrypted=true for rarext.dll here,
750-
// so it can recognize encrypted header archives in archive properties.
751-
#ifndef RAR_NOCRYPT
752743
byte Digest[SHA256_DIGEST_SIZE];
753744
sha256_get(CryptHead.PswCheck, SIZE_PSWCHECK, Digest);
754745

755746
CryptHead.UsePswCheck=memcmp(csum,Digest,SIZE_PSWCHECK_CSUM)==0;
756-
#endif
757747
}
758748
Encrypted=true;
759749
}
@@ -904,16 +894,6 @@ size_t Archive::ReadHeader50()
904894
if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_CMT))
905895
MainComment=true;
906896

907-
// For RAR5 format we read the user specified recovery percent here.
908-
if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_RR) && hd->SubData.size()>0)
909-
{
910-
// It is stored as a single byte up to RAR 6.02 and as vint since
911-
// 6.10, where we extended the maximum RR size from 99% to 1000%.
912-
RawRead RawPercent;
913-
RawPercent.Read(hd->SubData.data(),hd->SubData.size());
914-
RecoveryPercent=(int)RawPercent.GetV();
915-
916-
}
917897

918898
if (BadCRC) // Add the file name to broken header message displayed above.
919899
uiMsg(UIERROR_FHEADERBROKEN,Archive::FileName,hd->FileName);
@@ -1056,30 +1036,22 @@ void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb)
10561036
FileHeader *hd=(FileHeader *)bb;
10571037
switch(FieldType)
10581038
{
1059-
#ifndef RAR_NOCRYPT // Except rarext.dll, Setup.SFX and unrar_nocrypt.dll.
10601039
case FHEXTRA_CRYPT:
10611040
{
10621041
FileHeader *hd=(FileHeader *)bb;
10631042
uint EncVersion=(uint)Raw->GetV();
10641043
if (EncVersion>CRYPT_VERSION)
1065-
{
10661044
UnkEncVerMsg(hd->FileName,L"x" + std::to_wstring(EncVersion));
1067-
hd->CryptMethod=CRYPT_UNKNOWN;
1068-
}
10691045
else
10701046
{
10711047
uint Flags=(uint)Raw->GetV();
1048+
hd->UsePswCheck=(Flags & FHEXTRA_CRYPT_PSWCHECK)!=0;
1049+
hd->UseHashKey=(Flags & FHEXTRA_CRYPT_HASHMAC)!=0;
10721050
hd->Lg2Count=Raw->Get1();
10731051
if (hd->Lg2Count>CRYPT5_KDF_LG2_COUNT_MAX)
1074-
{
10751052
UnkEncVerMsg(hd->FileName,L"xc" + std::to_wstring(hd->Lg2Count));
1076-
hd->CryptMethod=CRYPT_UNKNOWN;
1077-
}
10781053
else
10791054
{
1080-
hd->UsePswCheck=(Flags & FHEXTRA_CRYPT_PSWCHECK)!=0;
1081-
hd->UseHashKey=(Flags & FHEXTRA_CRYPT_HASHMAC)!=0;
1082-
10831055
Raw->GetB(hd->Salt,SIZE_SALT50);
10841056
Raw->GetB(hd->InitV,SIZE_INITV);
10851057
if (hd->UsePswCheck)
@@ -1113,7 +1085,6 @@ void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb)
11131085
}
11141086
}
11151087
break;
1116-
#endif
11171088
case FHEXTRA_HASH:
11181089
{
11191090
FileHeader *hd=(FileHeader *)bb;
@@ -1318,7 +1289,7 @@ size_t Archive::ReadHeader14()
13181289
std::string FileName(NameSize,0);
13191290
Raw.GetB((byte *)&FileName[0],NameSize);
13201291
std::string NameA;
1321-
OemToExt(FileName,NameA);
1292+
IntToExt(FileName,NameA);
13221293
CharToWide(NameA,FileHead.FileName);
13231294
ConvertNameCase(FileHead.FileName);
13241295
ConvertFileHeader(&FileHead);

vendor/unrar/blake2s.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
#define BLAKE2_DIGEST_SIZE 32
66
#define BLAKE2_THREADS_NUMBER 8
77

8-
// Use constexpr instead of enums for -std=c++20 compatibility.
9-
constexpr size_t BLAKE2S_BLOCKBYTES = 64;
10-
constexpr size_t BLAKE2S_OUTBYTES = 32;
8+
enum blake2s_constant
9+
{
10+
BLAKE2S_BLOCKBYTES = 64,
11+
BLAKE2S_OUTBYTES = 32
12+
};
13+
1114

1215
// Alignment to 64 improves performance of both SSE and non-SSE versions.
1316
// Alignment to n*16 is required for SSE version, so we selected 64.

vendor/unrar/cmddata.cpp

Lines changed: 21 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ void CommandData::Init()
3838
InclArgs.Reset();
3939
ArcNames.Reset();
4040
StoreArgs.Reset();
41-
#ifdef PROPAGATE_MOTW
42-
MotwList.Reset();
43-
#endif
4441
Password.Clean();
4542
NextVolSizes.clear();
4643
#ifdef RARDLL
@@ -192,7 +189,7 @@ void CommandData::ParseDone()
192189
#if !defined(SFX_MODULE)
193190
void CommandData::ParseEnvVar()
194191
{
195-
char *EnvVar=getenv("RARINISWITCHES");
192+
char *EnvVar=getenv("RAR");
196193
if (EnvVar!=NULL)
197194
{
198195
std::wstring EnvStr;
@@ -296,9 +293,6 @@ void CommandData::ProcessSwitchesString(const std::wstring &Str)
296293
void CommandData::ProcessSwitch(const wchar *Switch)
297294
{
298295

299-
if (LargePageAlloc::ProcessSwitch(this,Switch))
300-
return;
301-
302296
switch(toupperw(Switch[0]))
303297
{
304298
case '@':
@@ -625,6 +619,8 @@ void CommandData::ProcessSwitch(const wchar *Switch)
625619
}
626620
}
627621
break;
622+
case 'M':
623+
break;
628624
case 'D':
629625
{
630626
bool SetDictLimit=toupperw(Switch[2])=='X';
@@ -669,30 +665,33 @@ void CommandData::ProcessSwitch(const wchar *Switch)
669665
if (toupperw(Switch[2])=='S' && Switch[3]==0)
670666
SkipEncrypted=true;
671667
break;
672-
case 'L':
673-
if (toupperw(Switch[2])=='P')
668+
case 'S':
674669
{
675-
UseLargePages=true;
676-
if (!LargePageAlloc::IsPrivilegeAssigned() && LargePageAlloc::AssignConfirmation())
670+
std::wstring StoreNames=(Switch[2]==0 ? DefaultStoreList:Switch+2);
671+
size_t Pos=0;
672+
while (Pos<StoreNames.size())
677673
{
678-
LargePageAlloc::AssignPrivilege();
679-
680-
// Quit immediately. We do not want to interrupt the current copy
681-
// archive processing with reboot after assigning privilege.
682-
SetupComplete=true;
674+
if (StoreNames[Pos]=='.')
675+
Pos++;
676+
size_t EndPos=StoreNames.find(';',Pos);
677+
std::wstring Mask=StoreNames.substr(Pos,EndPos==std::wstring::npos ? EndPos:EndPos-Pos);
678+
if (Mask.find_first_of(L"*?.")==std::wstring::npos)
679+
Mask.insert(0,L"*.");
680+
StoreArgs.AddString(Mask);
681+
if (EndPos==std::wstring::npos)
682+
break;
683+
Pos=EndPos+1;
683684
}
684685
}
685686
break;
686-
case 'M':
687-
break;
688-
case 'S':
689-
GetBriefMaskList(Switch[2]==0 ? DefaultStoreList:Switch+2,StoreArgs);
690-
break;
691687
#ifdef RAR_SMP
692688
case 'T':
693689
Threads=atoiw(Switch+2);
694690
if (Threads>MaxPoolThreads || Threads<1)
695691
BadSwitch(Switch);
692+
else
693+
{
694+
}
696695
break;
697696
#endif
698697
default:
@@ -753,18 +752,6 @@ void CommandData::ProcessSwitch(const wchar *Switch)
753752
}
754753
break;
755754
#endif
756-
#ifdef PROPAGATE_MOTW
757-
case 'M':
758-
{
759-
MotwAllFields=Switch[2]=='1';
760-
const wchar *Sep=wcschr(Switch+2,'=');
761-
if (Switch[2]=='-')
762-
MotwList.Reset();
763-
else
764-
GetBriefMaskList(Sep==nullptr ? L"*":Sep+1,MotwList);
765-
}
766-
break;
767-
#endif
768755
#ifdef _WIN_ALL
769756
case 'N':
770757
if (toupperw(Switch[2])=='I')
@@ -1046,11 +1033,6 @@ void CommandData::ProcessCommand()
10461033
#ifndef SFX_MODULE
10471034

10481035
const wchar *SingleCharCommands=L"FUADPXETK";
1049-
1050-
// RAR -mlp command is the legitimate way to assign the required privilege.
1051-
if (Command.empty() && UseLargePages || SetupComplete)
1052-
return;
1053-
10541036
if (Command[0]!=0 && Command[1]!=0 && wcschr(SingleCharCommands,Command[0])!=NULL || ArcName.empty())
10551037
OutHelp(Command.empty() ? RARX_SUCCESS:RARX_USERERROR); // Return 'success' for 'rar' without parameters.
10561038

@@ -1114,18 +1096,8 @@ void CommandData::ProcessCommand()
11141096
OutHelp(RARX_USERERROR);
11151097
#endif
11161098
}
1117-
1118-
// Since messages usually include '\n' in the beginning, we also issue
1119-
// the final '\n'. It is especially important in Unix, where otherwise
1120-
// the shell can display the prompt on the same line as the last message.
1121-
// mprintf is blocked with -idq and if error messages had been displayed
1122-
// in this mode, we use eprintf to separate them from shell prompt.
1123-
// If nothing was displayed with -idq, we avoid the excessive empty line.
11241099
if (!BareOutput)
1125-
if (MsgStream==MSG_ERRONLY && IsConsoleOutputPresent())
1126-
eprintf(L"\n");
1127-
else
1128-
mprintf(L"\n");
1100+
mprintf(L"\n");
11291101
}
11301102

11311103

@@ -1259,25 +1231,5 @@ int64 CommandData::GetVolSize(const wchar *S,uint DefMultiplier)
12591231
}
12601232

12611233

1262-
// Treat the list like rar;zip as *.rar;*.zip for -ms and similar switches.
1263-
void CommandData::GetBriefMaskList(const std::wstring &Masks,StringList &Args)
1264-
{
1265-
size_t Pos=0;
1266-
while (Pos<Masks.size())
1267-
{
1268-
if (Masks[Pos]=='.')
1269-
Pos++;
1270-
size_t EndPos=Masks.find(';',Pos);
1271-
std::wstring Mask=Masks.substr(Pos,EndPos==std::wstring::npos ? EndPos:EndPos-Pos);
1272-
if (Mask.find_first_of(L"*?.")==std::wstring::npos)
1273-
Mask.insert(0,L"*.");
1274-
Args.AddString(Mask);
1275-
if (EndPos==std::wstring::npos)
1276-
break;
1277-
Pos=EndPos+1;
1278-
}
1279-
}
1280-
1281-
12821234

12831235

0 commit comments

Comments
 (0)