Skip to content

Commit ee05ac9

Browse files
committed
Update unrar to 6.20
1 parent 05a7a74 commit ee05ac9

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

vendor/unrar/arcread.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb)
10001000
{
10011001
std::vector<char> NameU((size_t)NameSize); // UTF-8 name.
10021002
Raw->GetB(&NameU[0],(size_t)NameSize);
1003-
// If starts from 0, the name was longer han reserved space
1003+
// If starts from 0, the name was longer than reserved space
10041004
// when saving this extra field.
10051005
if (NameU[0]!=0)
10061006
{
@@ -1014,11 +1014,11 @@ void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,const BaseBlock *bb)
10141014
if ((Flags & MHEXTRA_METADATA_CTIME)!=0)
10151015
if ((Flags & MHEXTRA_METADATA_UNIXTIME)!=0)
10161016
if ((Flags & MHEXTRA_METADATA_UNIX_NS)!=0)
1017-
hd->OrigCtime.SetUnixNS(Raw->Get8());
1017+
hd->OrigTime.SetUnixNS(Raw->Get8());
10181018
else
1019-
hd->OrigCtime.SetUnix((time_t)Raw->Get4());
1019+
hd->OrigTime.SetUnix((time_t)Raw->Get4());
10201020
else
1021-
hd->OrigCtime.SetWin(Raw->Get8());
1021+
hd->OrigTime.SetWin(Raw->Get8());
10221022
}
10231023
break;
10241024
}

vendor/unrar/extract.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ CmdExtract::CmdExtract(CommandData *Cmd)
1616
// Common for all archives involved. Set here instead of DoExtract()
1717
// to use in unrar.dll too. Allows to avoid LinksToDirs() calls
1818
// and save CPU time in no symlinks including ".." in target were extracted.
19-
UpLinkExtracted=false;
19+
#if defined(_WIN_ALL)
20+
// We can't expand symlink path components in another symlink target
21+
// in Windows. We can't create symlinks in Android now. Even though we do not
22+
// really need LinksToDirs() calls in these systems, we still call it
23+
// for extra safety, but only if symlink with ".." in target was extracted.
24+
ConvertSymlinkPaths=false;
25+
#else
26+
// We enable it by default in Unix to care about the case when several
27+
// archives are unpacked to same directory with several independent RAR runs.
28+
// Worst case performance penalty for a lot of small files seems to be ~3%.
29+
ConvertSymlinkPaths=true;
30+
#endif
2031

2132
Unp=new Unpack(&DataIO);
2233
#ifdef RAR_SMP
@@ -486,6 +497,13 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat)
486497

487498
if (!Cmd->Test) // While harmless, it is useless for 't'.
488499
{
500+
// If reference source isn't selected, but target is selected,
501+
// we unpack the source under the temporary name and then rename
502+
// or copy it to target name. We do not unpack it under the target
503+
// name immediately, because the same source can be used by multiple
504+
// targets and it is possible that first target isn't unpacked
505+
// for some reason. Also targets might have associated service blocks
506+
// like ACLs. All this would complicate processing a lot.
489507
wcsncpyz(DestFileName,*Cmd->TempPath!=0 ? Cmd->TempPath:Cmd->ExtrPath,ASIZE(DestFileName));
490508
AddEndSlash(DestFileName,ASIZE(DestFileName));
491509
wcsncatz(DestFileName,L"__tmp_reference_source_",ASIZE(DestFileName));
@@ -627,7 +645,7 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat)
627645
#endif
628646

629647
if (ExtrFile && Command!='P' && !Cmd->Test && !Cmd->AbsoluteLinks &&
630-
UpLinkExtracted)
648+
ConvertSymlinkPaths)
631649
ExtrFile=LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink);
632650

633651
File CurFile;
@@ -786,7 +804,7 @@ bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat)
786804
{
787805
bool UpLink;
788806
LinkSuccess=ExtractSymlink(Cmd,DataIO,Arc,DestFileName,UpLink);
789-
UpLinkExtracted|=LinkSuccess && UpLink;
807+
ConvertSymlinkPaths|=LinkSuccess && UpLink;
790808

791809
// We do not actually need to reset the cache here if we cache
792810
// only the single last checked path, because at this point
@@ -1304,7 +1322,7 @@ void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName)
13041322
DirExist=FileExist(DestFileName) && IsDir(GetFileAttr(DestFileName));
13051323
if (!DirExist)
13061324
{
1307-
if (!Cmd->AbsoluteLinks && UpLinkExtracted)
1325+
if (!Cmd->AbsoluteLinks && ConvertSymlinkPaths)
13081326
LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink);
13091327
CreatePath(DestFileName,true,Cmd->DisableNames);
13101328
MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr);
@@ -1387,7 +1405,7 @@ bool CmdExtract::ExtrCreateFile(Archive &Arc,File &CurFile)
13871405

13881406
MakeNameUsable(DestFileName,true);
13891407

1390-
if (!Cmd->AbsoluteLinks && UpLinkExtracted)
1408+
if (!Cmd->AbsoluteLinks && ConvertSymlinkPaths)
13911409
LinksToDirs(DestFileName,Cmd->ExtrPath,LastCheckedSymlink);
13921410
CreatePath(DestFileName,true,Cmd->DisableNames);
13931411
if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))
@@ -1499,6 +1517,8 @@ void CmdExtract::AnalyzeArchive(const wchar *ArcName,bool Volume,bool NewNumberi
14991517
{
15001518
if (!MatchFound && !Arc.FileHead.Solid) // Can start extraction from here.
15011519
{
1520+
// We would gain nothing and unnecessarily complicate extraction
1521+
// by setting these values for first volume or first archived file.
15021522
if (!FirstVolume)
15031523
wcsncpyz(Analyze->StartName,NextName,ASIZE(Analyze->StartName));
15041524
if (!FirstFile)
@@ -1511,6 +1531,10 @@ void CmdExtract::AnalyzeArchive(const wchar *ArcName,bool Volume,bool NewNumberi
15111531
MatchFound = true;
15121532
PrevMatched = true;
15131533

1534+
// Reset the previously set early exit position, if any, because
1535+
// we found a new matched file.
1536+
Analyze->EndPos=0;
1537+
15141538
// Matched file reference pointing at maybe non-matched source file.
15151539
// Even though we know RedirName, we can't check if source file
15161540
// is certainly non-matched, because it can be filtered out by
@@ -1545,6 +1569,8 @@ void CmdExtract::AnalyzeArchive(const wchar *ArcName,bool Volume,bool NewNumberi
15451569
{
15461570
if (PrevMatched) // First non-matched item after matched.
15471571
{
1572+
// We would gain nothing and unnecessarily complicate extraction
1573+
// by setting these values for first volume or first archived file.
15481574
if (!FirstVolume)
15491575
wcsncpyz(Analyze->EndName,NextName,ASIZE(Analyze->EndName));
15501576
if (!FirstFile)

vendor/unrar/extract.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ class CmdExtract
7171
bool PrevProcessed; // If previous file was successfully extracted or tested.
7272
wchar DestFileName[NM];
7373
bool PasswordCancelled;
74-
bool UpLinkExtracted; // At least one symlink with ".." in target was extracted.
74+
75+
// In Windows it is set to true if at least one symlink with ".."
76+
// in target was extracted.
77+
bool ConvertSymlinkPaths;
7578

7679
// Last path checked for symlinks. We use it to improve the performance,
7780
// so we do not check recently checked folders again.

vendor/unrar/headers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct MainHeader:BaseBlock
170170
uint64 RRMaxSize; // Maximum size of RR offset in locator extra field.
171171
size_t MetaNameMaxSize; // Maximum size of archive name in metadata extra field.
172172
std::wstring OrigName; // Original archive name.
173-
RarTime OrigCtime; // Original archive creation time.
173+
RarTime OrigTime; // Original archive time.
174174

175175
void Reset();
176176
};

vendor/unrar/list.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ void ListArchive(CommandData *Cmd)
6565

6666
if (!Arc.MainHead.OrigName.empty())
6767
mprintf(L"\n%s: %s",St(MOrigName),Arc.MainHead.OrigName.c_str());
68-
if (Arc.MainHead.OrigCtime.IsSet())
68+
if (Arc.MainHead.OrigTime.IsSet())
6969
{
7070
wchar DateStr[50];
71-
Arc.MainHead.OrigCtime.GetText(DateStr,ASIZE(DateStr),Technical);
71+
Arc.MainHead.OrigTime.GetText(DateStr,ASIZE(DateStr),Technical);
7272
mprintf(L"\n%s: %s",St(MOriginalTime),DateStr);
7373
}
7474

vendor/unrar/version.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RARVER_MAJOR 6
22
#define RARVER_MINOR 20
3-
#define RARVER_BETA 3
4-
#define RARVER_DAY 15
5-
#define RARVER_MONTH 12
6-
#define RARVER_YEAR 2022
3+
#define RARVER_BETA 0
4+
#define RARVER_DAY 17
5+
#define RARVER_MONTH 1
6+
#define RARVER_YEAR 2023

0 commit comments

Comments
 (0)