Updated unrar to 3.7.8, patch by Ioan Molnar - thanks!

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22584 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-10-15 23:49:42 +00:00
parent 78878cabe8
commit 3dd4843b9d
24 changed files with 135 additions and 44 deletions

0
src/bin/unrar/Jamfile Executable file → Normal file
View File

View File

@ -46,9 +46,13 @@ bool Archive::GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW)
uint UnpCmtLength;
if (OldFormat)
{
#ifdef NOCRYPT
return(false);
#else
UnpCmtLength=GetByte()+(GetByte()<<8);
CmtLength-=2;
DataIO.SetCmt13Encryption();
#endif
}
else
UnpCmtLength=CommHead.UnpSize;

View File

@ -466,7 +466,7 @@ void CommandData::ProcessSwitch(char *Switch)
case 'N':
case 'X':
if (Switch[1]!=0)
{
{
StringList *Args=etoupper(Switch[0])=='N' ? InclArgs:ExclArgs;
if (Switch[1]=='@' && !IsWildcard(Switch))
{
@ -957,7 +957,7 @@ void CommandData::OutHelp()
#endif
#ifndef _WIN_32
static MSGID Win32Only[]={
MCHelpSwIEML,MCHelpSwVD,MCHelpSwAC,MCHelpSwAO,MCHelpSwOS,MCHelpSwIOFF,
MCHelpSwIEML,MCHelpSwVD,MCHelpSwAO,MCHelpSwOS,MCHelpSwIOFF,
MCHelpSwEP2,MCHelpSwOC
};
bool Found=false;
@ -974,6 +974,10 @@ void CommandData::OutHelp()
if (Help[I]==MCHelpSwOW)
continue;
#endif
#if !defined(_WIN_32) && !defined(_EMX)
if (Help[I]==MCHelpSwAC)
continue;
#endif
#ifndef SAVE_LINKS
if (Help[I]==MCHelpSwOL)
continue;
@ -1035,7 +1039,7 @@ bool CommandData::ExclCheck(char *CheckName,bool CheckFullPath)
return(true);
if (InclArgs->ItemsCount()==0)
return(false);
if (ExclCheckArgs(InclArgs,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
if (ExclCheckArgs(InclArgs,CheckName,false,MATCH_WILDSUBPATH))
return(false);
return(true);
}

View File

@ -326,12 +326,13 @@ void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataPro
Data->Cmd.ProcessDataProc=ProcessDataProc;
}
#ifndef NOCRYPT
void PASCAL RARSetPassword(HANDLE hArcData,char *Password)
{
DataSet *Data=(DataSet *)hArcData;
strncpyz(Data->Cmd.Password,Password,ASIZE(Data->Cmd.Password));
}
#endif
int PASCAL RARGetDllVersion()

View File

@ -143,6 +143,11 @@ EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
Arc.ViewComment();
// RAR can close a corrupt encrypted archive
if (!Arc.IsOpened())
return(EXTRACT_ARC_NEXT);
while (1)
{
int Size=Arc.ReadHeader();

View File

@ -253,10 +253,12 @@ void File::Flush()
bool File::Delete()
{
if (HandleType!=FILE_HANDLENORMAL || !AllowDelete)
if (HandleType!=FILE_HANDLENORMAL)
return(false);
if (hFile!=BAD_HANDLE)
Close();
if (!AllowDelete)
return(false);
return(DelFile(FileName,FileNameW));
}

View File

@ -43,7 +43,7 @@ MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,uint Attr)
bool CreatePath(const char *Path,const wchar *PathW,bool SkipLastName)
{
#ifdef _WIN_32
#if defined(_WIN_32) || defined(_EMX)
uint DirAttr=0;
#else
uint DirAttr=0777;
@ -211,6 +211,7 @@ Int64 GetFreeDisk(const char *Name)
return(1457664);
#elif defined(_EMX)
int Drive=(!isalpha(Name[0]) || Name[1]!=':') ? 0:etoupper(Name[0])-'A'+1;
#ifndef _DJGPP
if (_osmode == OS2_MODE)
{
FSALLOCATE fsa;
@ -221,12 +222,17 @@ Int64 GetFreeDisk(const char *Name)
return(FreeSize);
}
else
#endif
{
union REGS regs,outregs;
memset(&regs,0,sizeof(regs));
regs.h.ah=0x36;
regs.h.dl=Drive;
#ifdef _DJGPP
int86 (0x21,&regs,&outregs);
#else
_int86 (0x21,&regs,&outregs);
#endif
if (outregs.x.ax==0xffff)
return(1457664);
Int64 FreeSize=outregs.x.ax*outregs.x.cx;

View File

@ -162,7 +162,7 @@ bool FindFile::FastFind(const char *FindMask,const wchar *FindMaskW,struct FindD
return(false);
}
#ifdef _DJGPP
fd->FileAttr=chmod(FindMask,0);
fd->FileAttr=_chmod(FindMask,0);
#elif defined(_EMX)
fd->FileAttr=st.st_attr;
#else

View File

@ -38,6 +38,11 @@ void ListArchive(CommandData *Cmd)
if (!Bare)
{
Arc.ViewComment();
// RAR can close a corrupt encrypted archive
if (!Arc.IsOpened())
break;
mprintf("\n");
if (Arc.Solid)
mprintf(St(MListSolid));

View File

@ -527,6 +527,16 @@ inline void ModelPPM::ClearMask()
// reset PPM variables after data error allowing safe resuming
// of further data processing
void ModelPPM::CleanUp()
{
SubAlloc.StopSubAllocator();
SubAlloc.StartSubAllocator(1);
StartModelRare(2);
}
bool ModelPPM::DecodeInit(Unpack *UnpackRead,int &EscChar)
{
int MaxOrder=UnpackRead->GetChar();

View File

@ -124,6 +124,7 @@ class ModelPPM
inline void ClearMask();
public:
ModelPPM();
void CleanUp(); // reset PPM variables after data error
bool DecodeInit(Unpack *UnpackRead,int &EscChar);
int DecodeChar();
};

View File

@ -334,6 +334,7 @@ bool EnumConfigPaths(char *Path,int Number)
strcpy(RARFileName,Path);
if (Number!=0)
return(false);
#ifndef _DJGPP
if (_osmode==OS2_MODE)
{
PTIB ptib;
@ -342,6 +343,7 @@ bool EnumConfigPaths(char *Path,int Number)
DosQueryModuleName(ppib->pib_hmte,NM,Path);
}
else
#endif
strcpy(Path,RARFileName);
RemoveNameFromPath(Path);
return(true);
@ -476,8 +478,12 @@ bool IsNameUsable(const char *Name)
if (Name[0] && Name[1] && strchr(Name+2,':')!=NULL)
return(false);
for (const char *s=Name;*s!=0;s=charnext(s))
{
if (*s<32)
return(false);
if (*s==' ' && IsPathDiv(s[1]))
return(false);
}
#endif
return(*Name!=0 && strpbrk(Name,"?*<>|\"")==NULL);
}
@ -496,6 +502,8 @@ void MakeNameUsable(char *Name,bool Extended)
#ifndef _UNIX
if (s-Name>1 && *s==':')
*s='_';
if (*s==' ' && IsPathDiv(s[1]))
*s='_';
#endif
}
}

View File

@ -179,8 +179,10 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
VM_PreparedCommand *Cmd=PreparedCode;
while (1)
{
#ifndef NORARVM
uint *Op1=GetOperand(&Cmd->Op1);
uint *Op2=GetOperand(&Cmd->Op2);
#endif
switch(Cmd->OpCode)
{
#ifndef NORARVM
@ -506,7 +508,7 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
SET_VALUE(Cmd->ByteMode,Op1,Result);
}
break;
#endif
#endif // for #ifndef NORARVM
case VM_RET:
if (R[7]>=VM_MEMSIZE)
return(true);
@ -767,6 +769,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
case VM_CMP:
Cmd->OpCode=Cmd->ByteMode ? VM_CMPB:VM_CMPD;
continue;
default:
break;
}
if ((VM_CmdFlags[Cmd->OpCode] & VMCF_CHFLAGS)==0)
continue;
@ -801,6 +805,8 @@ void RarVM::Optimize(VM_PreparedProgram *Prg)
case VM_NEG:
Cmd->OpCode=Cmd->ByteMode ? VM_NEGB:VM_NEGD;
continue;
default:
break;
}
}
}
@ -843,12 +849,12 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
int DataSize=R[4];
uint FileOffset=R[6];
if (DataSize>=VM_GLOBALMEMADDR)
if (DataSize>=VM_GLOBALMEMADDR || DataSize<4)
break;
const int FileSize=0x1000000;
byte CmpByte2=FilterType==VMSF_E8E9 ? 0xe9:0xe8;
for (uint CurPos=0;CurPos<DataSize-4;)
for (int CurPos=0;CurPos<DataSize-4;)
{
byte CurByte=*(Data++);
CurPos++;
@ -889,10 +895,10 @@ void RarVM::ExecuteStandardFilter(VM_StandardFilters FilterType)
int DataSize=R[4];
uint FileOffset=R[6];
if (DataSize>=VM_GLOBALMEMADDR)
if (DataSize>=VM_GLOBALMEMADDR || DataSize<21)
break;
uint CurPos=0;
int CurPos=0;
FileOffset>>=4;

View File

@ -62,9 +62,13 @@ int ComprDataIO::UnpRead(byte *Addr,uint Count)
PackedCRC=CRC(PackedCRC,ReadAddr,ReadSize);
}
CurUnpRead+=RetCode;
ReadAddr+=RetCode;
TotalRead+=RetCode;
#ifndef NOVOLUME
// these variable are not used below in NOVOLUME mode, so it is better
// to exclude these commands to avoid compiler warnings
ReadAddr+=RetCode;
Count-=RetCode;
#endif
UnpPackedSize-=RetCode;
if (UnpPackedSize == 0 && UnpVolume)
{
@ -230,7 +234,7 @@ void ComprDataIO::SetEncryption(int Method,char *Password,byte *Salt,bool Encryp
}
#ifndef SFX_MODULE
#if !defined(SFX_MODULE) && !defined(NOCRYPT)
void ComprDataIO::SetAV15Encryption()
{
Decryption=15;
@ -239,7 +243,7 @@ void ComprDataIO::SetAV15Encryption()
#endif
#ifndef SFX_MODULE
#if !defined(SFX_MODULE) && !defined(NOCRYPT)
void ComprDataIO::SetCmt13Encryption()
{
Decryption=13;

View File

@ -47,6 +47,7 @@
Steve Reid SHA-1 hash function
Marcus Herbert makefile.unix file
Tomasz Klim fixes for libunrar.so
Robert Riebisch makefile.dj and patches for DJGPP
4. Legal stuff

View File

@ -154,8 +154,19 @@ int ScanTree::FindProc(FindData *FindData)
bool Error=FindData->Error;
#ifdef _WIN_32
if (Error && strstr(CurMask,"System Volume Information\\")!=NULL)
Error=false;
if (Error)
{
// Do not display an error if we cannot scan contents of reparse
// point. Vista contains a lot of reparse (or junction) points,
// which are not accessible.
if ((FindData->FileAttr & FILE_ATTRIBUTE_REPARSE_POINT)!=0)
Error=false;
// Do not display an error if we cannot scan contents of
// "System Volume Information" folder. Normally it is not accessible.
if (strstr(CurMask,"System Volume Information\\")!=NULL)
Error=false;
}
#endif
if (Cmd!=NULL && Cmd->ExclCheck(CurMask,true))

View File

@ -12,11 +12,6 @@ void InitSystemOptions(int SleepTime)
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
#if defined(_WIN_32) && !defined(BELOW_NORMAL_PRIORITY_CLASS)
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#endif
void SetPriority(int Priority)
{
#ifdef _WIN_32
@ -61,6 +56,11 @@ void SetPriority(int Priority)
}
SetPriorityClass(GetCurrentProcess(),PriorityClass);
SetThreadPriority(GetCurrentThread(),PriorityLevel);
// background mode for Vista, too slow for real life use
// if (WinNT()>=6 && Priority==1)
// SetPriorityClass(GetCurrentProcess(),PROCESS_MODE_BACKGROUND_BEGIN);
#endif
}
#endif
@ -79,12 +79,6 @@ void Wait()
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) && !defined(SHELL_EXT)
#ifndef SHTDN_REASON_MAJOR_APPLICATION
#define SHTDN_REASON_MAJOR_APPLICATION 0x00040000
#define SHTDN_REASON_FLAG_PLANNED 0x80000000
#define SHTDN_REASON_MINOR_MAINTENANCE 0x00000001
#endif
void Shutdown()
{
HANDLE hToken;

View File

@ -1,6 +1,22 @@
#ifndef _RAR_SYSTEM_
#define _RAR_SYSTEM_
#ifdef _WIN_32
#ifndef BELOW_NORMAL_PRIORITY_CLASS
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#endif
#ifndef PROCESS_MODE_BACKGROUND_BEGIN
#define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000
#define PROCESS_MODE_BACKGROUND_END 0x00200000
#endif
#ifndef SHTDN_REASON_MAJOR_APPLICATION
#define SHTDN_REASON_MAJOR_APPLICATION 0x00040000
#define SHTDN_REASON_FLAG_PLANNED 0x80000000
#define SHTDN_REASON_MINOR_MAINTENANCE 0x00000001
#endif
#endif
void InitSystemOptions(int SleepTime);
void SetPriority(int Priority);
void Wait();

View File

@ -43,6 +43,12 @@ void Unpack::Init(byte *Window)
ExternalWindow=true;
}
UnpInitData(false);
#ifndef SFX_MODULE
// RAR 1.5 decompression initialization
OldUnpInitData(false);
InitHuff();
#endif
}
@ -190,9 +196,6 @@ void Unpack::Unpack29(bool Solid)
return;
}
if (PPMError)
return;
while (true)
{
UnpPtr&=MAXWINMASK;
@ -218,7 +221,11 @@ void Unpack::Unpack29(bool Solid)
int Ch=PPM.DecodeChar();
if (Ch==-1)
{
PPMError=true;
PPM.CleanUp();
// turn off PPM compression mode in case of error, so UnRAR will
// call PPM.DecodeInit in case it needs to turn it on back later.
UnpBlockType=BLOCK_LZ;
break;
}
if (Ch==PPMEscChar)
@ -935,13 +942,18 @@ void Unpack::UnpInitData(int Solid)
LastDist=LastLength=0;
// memset(Window,0,MAXWINSIZE);
memset(UnpOldTable,0,sizeof(UnpOldTable));
memset(&LD,0,sizeof(LD));
memset(&DD,0,sizeof(DD));
memset(&LDD,0,sizeof(LDD));
memset(&RD,0,sizeof(RD));
memset(&BD,0,sizeof(BD));
UnpPtr=WrPtr=0;
PPMEscChar=2;
UnpBlockType=BLOCK_LZ;
InitFilters();
}
InitBitInput();
PPMError=false;
WrittenFileSize=0;
ReadTop=0;
ReadBorder=0;

View File

@ -159,7 +159,6 @@ class Unpack:private BitInput
bool UnpSomeRead;
Int64 WrittenFileSize;
bool FileExtracted;
bool PPMError;
int PrevLowDist,LowDistRepCount;

View File

@ -269,10 +269,12 @@ void Unpack::UnpInitData20(int Solid)
{
if (!Solid)
{
UnpChannelDelta=UnpCurChannel=0;
UnpAudioBlock=UnpChannelDelta=UnpCurChannel=0;
UnpChannels=1;
memset(AudV,0,sizeof(AudV));
memset(UnpOldTable20,0,sizeof(UnpOldTable20));
memset(MD,0,sizeof(MD));
}
}

6
src/bin/unrar/unrar.rdef Executable file → Normal file
View File

@ -5,9 +5,9 @@ resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP;
resource app_version {
major = 3,
middle = 7,
minor = 6,
minor = 8,
variety = 0,
internal = 0,
short_info = "3.76",
long_info = "3.76 Alexander Roshal"
short_info = "3.78",
long_info = "3.78 Alexander Roshal"
};

View File

@ -1,6 +1,6 @@
#define RARVER_MAJOR 3
#define RARVER_MINOR 70
#define RARVER_BETA 0
#define RARVER_DAY 22
#define RARVER_MONTH 5
#define RARVER_MINOR 71
#define RARVER_BETA 1
#define RARVER_DAY 10
#define RARVER_MONTH 9
#define RARVER_YEAR 2007

View File

@ -97,7 +97,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
break;
}
}
#else
#else // RARDLL
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
if (!RecoveryDone)
@ -123,8 +123,8 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
FailedOpen=true;
break;
}
#endif // RARDLL
*NextNameW=0;
#endif
}
if (FailedOpen)
{