Skip to content

Commit

Permalink
Integrate version 5.7.3 from https://www.rarlab.com/rar/unrarsrc-5.7.…
Browse files Browse the repository at this point in the history
  • Loading branch information
aawc authored May 1, 2019
1 parent 92c3e6d commit 08a782c
Show file tree
Hide file tree
Showing 35 changed files with 611 additions and 465 deletions.
4 changes: 3 additions & 1 deletion arccmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool Archive::GetComment(Array<wchar> *CmtData)
#ifndef SFX_MODULE
// Old style (RAR 2.9) comment header embedded into the main
// archive header.
if (BrokenHeader)
if (BrokenHeader || CommHead.HeadSize<SIZEOF_COMMHEAD)
{
uiMsg(UIERROR_CMTBROKEN,FileName);
return false;
Expand All @@ -57,6 +57,8 @@ bool Archive::GetComment(Array<wchar> *CmtData)
#else
UnpCmtLength=GetByte();
UnpCmtLength+=(GetByte()<<8);
if (CmtLength<2)
return false;
CmtLength-=2;
DataIO.SetCmt13Encryption();
CommHead.UnpVer=15;
Expand Down
2 changes: 1 addition & 1 deletion archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Archive:public File
void AddSubData(byte *SrcData,uint64 DataSize,File *SrcFile,
const wchar *Name,uint Flags);
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
HEADER_TYPE GetHeaderType() {return CurHeaderType;};
HEADER_TYPE GetHeaderType() {return CurHeaderType;}
RAROptions* GetRAROptions() {return Cmd;}
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
#if 0
Expand Down
30 changes: 15 additions & 15 deletions arcread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ size_t Archive::ReadHeader15()
if (ShortBlock.HeaderType==HEAD_MAIN && (ShortBlock.Flags & MHD_COMMENT)!=0)
{
// Old style (up to RAR 2.9) main archive comment embedded into
// the main archive header found. While we can read the entire
// the main archive header found. While we can read the entire
// ShortBlock.HeadSize here and remove this part of "if", it would be
// waste of memory, because we'll read and process this comment data
// in other function anyway and we do not need them here now.
Expand All @@ -230,7 +230,7 @@ size_t Archive::ReadHeader15()
Encrypted=(MainHead.Flags & MHD_PASSWORD)!=0;
Signed=MainHead.PosAV!=0 || MainHead.HighPosAV!=0;
MainHead.CommentInHeader=(MainHead.Flags & MHD_COMMENT)!=0;

// Only for encrypted 3.0+ archives. 2.x archives did not have this
// flag, so for non-encrypted archives, we'll set it later based on
// file attributes.
Expand All @@ -257,7 +257,7 @@ size_t Archive::ReadHeader15()
hd->WinSize=hd->Dir ? 0:0x10000<<((hd->Flags & LHD_WINDOWMASK)>>5);
hd->CommentInHeader=(hd->Flags & LHD_COMMENT)!=0;
hd->Version=(hd->Flags & LHD_VERSION)!=0;

hd->DataSize=Raw.Get4();
uint LowUnpSize=Raw.Get4();
hd->HostOS=Raw.Get1();
Expand All @@ -282,7 +282,7 @@ size_t Archive::ReadHeader15()
{
case 13: hd->CryptMethod=CRYPT_RAR13; break;
case 15: hd->CryptMethod=CRYPT_RAR15; break;
case 20:
case 20:
case 26: hd->CryptMethod=CRYPT_RAR20; break;
default: hd->CryptMethod=CRYPT_RAR30; break;
}
Expand All @@ -304,7 +304,7 @@ size_t Archive::ReadHeader15()
}

hd->Inherited=!FileBlock && (hd->SubFlags & SUBHEAD_FLAGS_INHERITED)!=0;

hd->LargeFile=(hd->Flags & LHD_LARGE)!=0;

uint HighPackSize,HighUnpSize;
Expand All @@ -314,7 +314,7 @@ size_t Archive::ReadHeader15()
HighUnpSize=Raw.Get4();
hd->UnknownUnpSize=(LowUnpSize==0xffffffff && HighUnpSize==0xffffffff);
}
else
else
{
HighPackSize=HighUnpSize=0;
// UnpSize equal to 0xffffffff without LHD_LARGE flag indicates
Expand Down Expand Up @@ -509,7 +509,7 @@ size_t Archive::ReadHeader15()
NextBlockPos+=Raw.Get4();
break;
}

ushort HeaderCRC=Raw.GetCRC15(false);

// Old AV header does not have header CRC properly set.
Expand Down Expand Up @@ -644,7 +644,7 @@ size_t Archive::ReadHeader50()
BrokenHeaderMsg();
return 0;
}

Raw.Read(SizeToRead);

if (Raw.Size()<HeaderSize)
Expand Down Expand Up @@ -677,7 +677,7 @@ size_t Archive::ReadHeader50()
return 0;
}
}

uint64 ExtraSize=0;
if ((ShortBlock.Flags & HFL_EXTRA)!=0)
{
Expand Down Expand Up @@ -770,7 +770,7 @@ size_t Archive::ReadHeader50()
// to not break normal archive processing by calling function.
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;
HEADER_TYPE SaveCurHeaderType=CurHeaderType;

QOpen.Init(this,false);
QOpen.Load(MainHead.QOpenOffset);

Expand All @@ -795,7 +795,7 @@ size_t Archive::ReadHeader50()
hd->PackSize=DataSize;
hd->FileFlags=(uint)Raw.GetV();
hd->UnpSize=Raw.GetV();

hd->UnknownUnpSize=(hd->FileFlags & FHFL_UNPUNKNOWN)!=0;
if (hd->UnknownUnpSize)
hd->UnpSize=INT64NDF;
Expand Down Expand Up @@ -882,7 +882,7 @@ size_t Archive::ReadHeader50()
RecoverySize=Header.RecSectionSize*Header.RecCount;
}
#endif

if (BadCRC) // Add the file name to broken header message displayed above.
uiMsg(UIERROR_FHEADERBROKEN,Archive::FileName,hd->FileName);
}
Expand Down Expand Up @@ -1307,7 +1307,7 @@ void Archive::ConvertAttributes()

if (mask == (mode_t) -1)
{
// umask call returns the current umask value. Argument (022) is not
// umask call returns the current umask value. Argument (022) is not
// really important here.
mask = umask(022);

Expand Down Expand Up @@ -1384,8 +1384,8 @@ void Archive::ConvertFileHeader(FileHeader *hd)

// ':' in file names is allowed in Unix, but not in Windows.
// Even worse, file data will be written to NTFS stream on NTFS,
// so automatic name correction on file create error in extraction
// routine does not work. In Windows and DOS versions we better
// so automatic name correction on file create error in extraction
// routine does not work. In Windows and DOS versions we better
// replace ':' now.
if (*s==':')
*s='_';
Expand Down
Loading

0 comments on commit 08a782c

Please sign in to comment.