Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unrar version 6.0.3 #25

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acknow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* RAR uses CRC32 function based on Intel Slicing-by-8 algorithm.
Original Intel Slicing-by-8 code is available here:

http://sourceforge.net/projects/slicing-by-8/
https://sourceforge.net/projects/slicing-by-8/

Original Intel Slicing-by-8 code is licensed under BSD License
available at http://www.opensource.org/licenses/bsd-license.html
Expand Down
11 changes: 9 additions & 2 deletions arccmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ bool Archive::GetComment(Array<wchar> *CmtData)
{
if (!MainComment)
return false;
SaveFilePos SavePos(*this);
int64 SavePos=Tell();
bool Success=DoGetComment(CmtData);
Seek(SavePos,SEEK_SET);
return Success;
}


bool Archive::DoGetComment(Array<wchar> *CmtData)
{
#ifndef SFX_MODULE
uint CmtLength;
if (Format==RARFMT14)
Expand Down Expand Up @@ -136,7 +143,7 @@ bool Archive::GetComment(Array<wchar> *CmtData)
bool Archive::ReadCommentData(Array<wchar> *CmtData)
{
Array<byte> CmtRaw;
if (!ReadSubData(&CmtRaw,NULL))
if (!ReadSubData(&CmtRaw,NULL,false))
return false;
size_t CmtSize=CmtRaw.Size();
CmtRaw.Push(0);
Expand Down
7 changes: 4 additions & 3 deletions archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ bool Archive::IsArchive(bool EnableBroken)
break;
}

// This check allows to make RS based recovery even if password is incorrect.
// But we should not do it for EnableBroken or we'll get 'not RAR archive'

// We should not do it for EnableBroken or we'll get 'not RAR archive'
// messages when extracting encrypted archives with wrong password.
if (FailedHeaderDecryption && !EnableBroken)
return false;
Expand All @@ -233,7 +233,7 @@ bool Archive::IsArchive(bool EnableBroken)
// immediately after IsArchive call.
if (HeadersLeft && (!SilentOpen || !Encrypted))
{
SaveFilePos SavePos(*this);
int64 SavePos=Tell();
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;
HEADER_TYPE SaveCurHeaderType=CurHeaderType;

Expand Down Expand Up @@ -262,6 +262,7 @@ bool Archive::IsArchive(bool EnableBroken)
CurBlockPos=SaveCurBlockPos;
NextBlockPos=SaveNextBlockPos;
CurHeaderType=SaveCurHeaderType;
Seek(SavePos,SEEK_SET);
}
if (!Volume || FirstVolume)
wcsncpyz(FirstVolumeName,FileName,ASIZE(FirstVolumeName));
Expand Down
6 changes: 2 additions & 4 deletions archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Archive:public File
void UpdateLatestTime(FileHeader *CurBlock);
void ConvertNameCase(wchar *Name);
void ConvertFileHeader(FileHeader *hd);
void WriteBlock50(HEADER_TYPE HeaderType,BaseBlock *wb,bool OnlySetSize,bool NonFinalWrite);
size_t ReadHeader14();
size_t ReadHeader15();
size_t ReadHeader50();
Expand All @@ -38,6 +37,7 @@ class Archive:public File
void UnexpEndArcMsg();
void BrokenHeaderMsg();
void UnkEncVerMsg(const wchar *Name,const wchar *Info);
bool DoGetComment(Array<wchar> *CmtData);
bool ReadCommentData(Array<wchar> *CmtData);

#if !defined(RAR_NOCRYPT)
Expand Down Expand Up @@ -65,8 +65,6 @@ class Archive:public File
size_t SearchBlock(HEADER_TYPE HeaderType);
size_t SearchSubBlock(const wchar *Type);
size_t SearchRR();
void WriteBlock(HEADER_TYPE HeaderType,BaseBlock *wb=NULL,bool OnlySetSize=false,bool NonFinalWrite=false);
void SetBlockSize(HEADER_TYPE HeaderType,BaseBlock *wb=NULL) {WriteBlock(HeaderType,wb,true);}
size_t ReadHeader();
void CheckArc(bool EnableBroken);
void CheckOpen(const wchar *Name);
Expand All @@ -83,7 +81,7 @@ class Archive:public File
int64 GetStartPos();
void AddSubData(byte *SrcData,uint64 DataSize,File *SrcFile,
const wchar *Name,uint Flags);
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
bool ReadSubData(Array<byte> *UnpData,File *DestFile,bool TestMode);
HEADER_TYPE GetHeaderType() {return CurHeaderType;}
RAROptions* GetRAROptions() {return Cmd;}
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
Expand Down
29 changes: 16 additions & 13 deletions arcread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ size_t Archive::ReadHeader15()
uint FileTime=Raw.Get4();
hd->UnpVer=Raw.Get1();

// RAR15 did not use the special dictionary size to mark dirs.
if (hd->UnpVer<20 && (hd->FileAttr & 0x10)!=0)
hd->Dir=true;

hd->Method=Raw.Get1()-0x30;
size_t NameSize=Raw.Get2();
hd->FileAttr=Raw.Get4();

// RAR15 did not use the special dictionary size to mark dirs.
if (hd->UnpVer<20 && (hd->FileAttr & 0x10)!=0)
hd->Dir=true;

hd->CryptMethod=CRYPT_NONE;
if (hd->Encrypted)
switch(hd->UnpVer)
Expand Down Expand Up @@ -402,8 +402,8 @@ size_t Archive::ReadHeader15()
if (rmode & 4)
rlt.Second++;
rlt.Reminder=0;
int count=rmode&3;
for (int J=0;J<count;J++)
uint count=rmode&3;
for (uint J=0;J<count;J++)
{
byte CurByte=Raw.Get1();
rlt.Reminder|=(((uint)CurByte)<<((J+3-count)*8));
Expand Down Expand Up @@ -521,7 +521,6 @@ size_t Archive::ReadHeader15()
{
// Last 7 bytes of recovered volume can contain zeroes, because
// REV files store its own information (volume number, etc.) here.
SaveFilePos SavePos(*this);
int64 Length=Tell();
Seek(Length-7,SEEK_SET);
Recovered=true;
Expand Down Expand Up @@ -584,7 +583,7 @@ size_t Archive::ReadHeader50()
{
// This message is used by Android GUI to reset cached passwords.
// Update appropriate code if changed.
uiMsg(UIERROR_BADPSW,FileName);
uiMsg(UIERROR_BADPSW,FileName,FileName);
FailedHeaderDecryption=true;
ErrHandler.SetErrorCode(RARX_BADPWD);
return 0;
Expand All @@ -593,7 +592,7 @@ size_t Archive::ReadHeader50()
{
// This message is used by Android GUI and Windows GUI and SFX to
// reset cached passwords. Update appropriate code if changed.
uiMsg(UIWAIT_BADPSW,FileName);
uiMsg(UIWAIT_BADPSW,FileName,FileName);
Cmd->Password.Clean();
}

Expand Down Expand Up @@ -720,6 +719,7 @@ size_t Archive::ReadHeader50()
UnkEncVerMsg(FileName,Info);
return 0;
}

Raw.GetB(CryptHead.Salt,SIZE_SALT50);
if (CryptHead.UsePswCheck)
{
Expand Down Expand Up @@ -785,7 +785,7 @@ size_t Archive::ReadHeader50()
case HEAD_SERVICE:
{
FileHeader *hd=ShortBlock.HeaderType==HEAD_FILE ? &FileHead:&SubHead;
hd->Reset();
hd->Reset(); // Clear hash, time fields and other stuff like flags.
*(BaseBlock *)hd=ShortBlock;

bool FileBlock=ShortBlock.HeaderType==HEAD_FILE;
Expand Down Expand Up @@ -1256,11 +1256,13 @@ size_t Archive::ReadHeader14()
Raw.Read(NameSize);

char FileName[NM];
Raw.GetB((byte *)FileName,Min(NameSize,ASIZE(FileName)));
FileName[NameSize]=0;
size_t ReadNameSize=Min(NameSize,ASIZE(FileName)-1);
Raw.GetB((byte *)FileName,ReadNameSize);
FileName[ReadNameSize]=0;
IntToExt(FileName,FileName,ASIZE(FileName));
CharToWide(FileName,FileHead.FileName,ASIZE(FileHead.FileName));
ConvertNameCase(FileHead.FileName);
ConvertFileHeader(&FileHead);

if (Raw.Size()!=0)
NextBlockPos=CurBlockPos+FileHead.HeadSize+FileHead.PackSize;
Expand Down Expand Up @@ -1414,7 +1416,7 @@ int64 Archive::GetStartPos()
}


bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile,bool TestMode)
{
if (BrokenHeader)
{
Expand Down Expand Up @@ -1462,6 +1464,7 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
SubDataIO.SetPackedSizeToRead(SubHead.PackSize);
SubDataIO.EnableShowProgress(false);
SubDataIO.SetFiles(this,DestFile);
SubDataIO.SetTestMode(TestMode);
SubDataIO.UnpVolume=SubHead.SplitAfter;
SubDataIO.SetSubHeader(&SubHead,NULL);
Unpack.SetDestSize(SubHead.UnpSize);
Expand Down
1 change: 1 addition & 0 deletions blake2s.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define _RAR_BLAKE2_

#define BLAKE2_DIGEST_SIZE 32
#define BLAKE2_THREADS_NUMBER 8

enum blake2s_constant
{
Expand Down
Loading