Skip to content

Commit

Permalink
unrar: update to 6.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Nov 15, 2021
1 parent 18eca2d commit 53f4b93
Show file tree
Hide file tree
Showing 45 changed files with 481 additions and 404 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ else()
endif()

set(UNRAR_VERSION_MAJOR 6)
set(UNRAR_VERSION_MINOR 0)
set(UNRAR_VERSION_PATCH 6)
set(UNRAR_VERSION_MINOR 10)
set(UNRAR_VERSION_PATCH 2)
set(PACKAGE_VERSION "${UNRAR_VERSION_MAJOR}.${UNRAR_VERSION_MINOR}.${UNRAR_VERSION_PATCH}")

string(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" UNRAR_ARCH_NAME)
Expand Down
47 changes: 7 additions & 40 deletions unrar/acknow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,16 @@
for samples and ideas allowed to make Reed-Solomon coding
more efficient.

* RAR text compression algorithm is based on Dmitry Shkarin PPMII
* RAR4 text compression algorithm is based on Dmitry Shkarin PPMII
and Dmitry Subbotin carryless rangecoder public domain source code.
You may find it in ftp.elf.stuba.sk/pub/pc/pack.
You can find it in ftp.elf.stuba.sk/pub/pc/pack.

* RAR encryption includes parts of code from Szymon Stefanek
and Brian Gladman AES implementations also as Steve Reid SHA-1 source.
* RAR encryption includes parts of public domain code
from Szymon Stefanek AES and Steve Reid SHA-1 implementations.

---------------------------------------------------------------------------
Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
All rights reserved.

LICENSE TERMS

The free distribution and use of this software in both source and binary
form is allowed (with or without changes) provided that:

1. distributions of this source code include the above copyright
notice, this list of conditions and the following disclaimer;

2. distributions in binary form include the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other associated materials;

3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.

ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
in which case the provisions of the GPL apply INSTEAD OF those given above.

DISCLAIMER

This software is provided 'as is' with no explicit or implied warranties
in respect of its properties, including, but not limited to, correctness
and/or fitness for purpose.
---------------------------------------------------------------------------

Source code of this package also as other cryptographic technology
and computing project related links are available on Brian Gladman's
web site: http://www.gladman.me.uk

* RAR uses CRC32 function based on Intel Slicing-by-8 algorithm.
Original Intel Slicing-by-8 code is available here:
* With exception of SFX modules, RAR uses CRC32 function based
on Intel Slicing-by-8 algorithm. Original Intel Slicing-by-8 code
is available here:

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

Expand Down
2 changes: 1 addition & 1 deletion unrar/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ bool Archive::IsArchive(bool EnableBroken)
// first file header to set "comment" flag when reading service header.
// Unless we are in silent mode, we need to know about presence of comment
// immediately after IsArchive call.
if (HeadersLeft && (!SilentOpen || !Encrypted))
if (HeadersLeft && (!SilentOpen || !Encrypted) && IsSeekable())
{
int64 SavePos=Tell();
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;
Expand Down
14 changes: 13 additions & 1 deletion unrar/arcread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@ size_t Archive::ReadHeader50()
return 0;
#else

if (Cmd->SkipEncrypted)
{
uiMsg(UIMSG_SKIPENCARC,FileName);
FailedHeaderDecryption=true; // Suppress error messages and quit quietly.
return 0;
}

byte HeadersInitV[SIZE_INITV];
if (Read(HeadersInitV,SIZE_INITV)!=SIZE_INITV)
{
Expand Down Expand Up @@ -876,7 +883,12 @@ size_t Archive::ReadHeader50()
// code to shell extension, which is not done now.
if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_RR) && hd->SubData.Size()>0)
{
RecoveryPercent=hd->SubData[0];
// It is stored as a single byte up to RAR 6.02 and as vint since
// 6.10, where we extended the maximum RR size from 99% to 1000%.
RawRead RawPercent;
RawPercent.Read(&hd->SubData[0],hd->SubData.Size());
RecoveryPercent=(int)RawPercent.GetV();

RSBlockHeader Header;
GetRRInfo(this,&Header);
RecoverySize=Header.RecSectionSize*Header.RecCount;
Expand Down
26 changes: 25 additions & 1 deletion unrar/cmddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ void CommandData::ParseArg(wchar *Arg)
// 'S' can contain SFX name, which case is important in Unix.
if (*Command!='I' && *Command!='S')
wcsupper(Command);
if (*Command=='P') // Enforce -idq for print command.
{
MsgStream=MSG_ERRONLY;
SetConsoleMsgStream(MSG_ERRONLY);
}
}
else
if (*ArcName==0)
Expand Down Expand Up @@ -373,6 +378,9 @@ void CommandData::ProcessSwitch(const wchar *Switch)
case '3':
ExclPath=EXCL_ABSPATH;
break;
case '4':
wcsncpyz(ExclArcPath,Switch+3,ASIZE(ExclArcPath));
break;
}
break;
default:
Expand All @@ -399,6 +407,8 @@ void CommandData::ProcessSwitch(const wchar *Switch)
EncryptHeaders=true;
if (Switch[2]!=0)
{
if (wcslen(Switch+2)>=MAXPASSWORD)
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
Password.Set(Switch+2);
cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
}
Expand Down Expand Up @@ -561,6 +571,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
break;
case 'D':
break;
case 'E':
if (toupperw(Switch[2])=='S' && Switch[3]==0)
SkipEncrypted=true;
break;
case 'S':
{
wchar StoreNames[1024];
Expand Down Expand Up @@ -648,6 +662,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
AllowIncompatNames=true;
break;
#endif
case 'P':
wcsncpyz(ExtrPath,Switch+2,ASIZE(ExtrPath));
AddEndSlash(ExtrPath,ASIZE(ExtrPath));
break;
case 'R':
Overwrite=OVERWRITE_AUTORENAME;
break;
Expand All @@ -672,6 +690,8 @@ void CommandData::ProcessSwitch(const wchar *Switch)
}
else
{
if (wcslen(Switch+1)>=MAXPASSWORD)
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
Password.Set(Switch+1);
cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
}
Expand Down Expand Up @@ -752,6 +772,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
case 'D':
Solid|=SOLID_VOLUME_DEPENDENT;
break;
case 'I':
ProhibitConsoleInput();
wcsncpyz(UseStdin,Switch[2] ? Switch+2:L"stdin",ASIZE(UseStdin));
break;
case 'L':
if (IsDigit(Switch[2]))
FileSizeLess=atoilw(Switch+2);
Expand Down Expand Up @@ -935,7 +959,7 @@ void CommandData::ProcessCommand()
wcsncpyz(ArcName,Name,ASIZE(ArcName));
}

if (wcschr(L"AFUMD",*Command)==NULL)
if (wcschr(L"AFUMD",*Command)==NULL && *UseStdin==0)
{
if (GenerateArcName)
{
Expand Down
2 changes: 1 addition & 1 deletion unrar/cmddata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CommandData:public RAROptions
bool GetArcName(wchar *Name,int MaxSize);
bool CheckWinSize();

int GetRecoverySize(const wchar *Str,int DefSize);
int GetRecoverySize(const wchar *CmdStr,const wchar *Value,int DefSize);

#ifndef SFX_MODULE
void ReportWrongSwitches(RARFORMAT Format);
Expand Down
2 changes: 2 additions & 0 deletions unrar/cmdfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ bool CommandData::TimeCheck(RarTime &ftm,RarTime &ftc,RarTime &fta)
// Return 'true' if we need to exclude the file from processing.
bool CommandData::SizeCheck(int64 Size)
{
if (Size==INT64NDF) // If called from archive formats like bzip2, not storing the file size.
return false;
if (FileSizeLess!=INT64NDF && Size>=FileSizeLess)
return true;
if (FileSizeMore!=INT64NDF && Size<=FileSizeMore)
Expand Down
16 changes: 8 additions & 8 deletions unrar/cmdmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
MUNRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdE,MCHelpCmdL,
MCHelpCmdP,MCHelpCmdT,MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm,
MCHelpSwAT,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,MCHelpSwAI,MCHelpSwAP,
MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,
MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSL,MCHelpSwSM,
MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,
MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,
MCHelpSwY
MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,MCHelpSwDH,MCHelpSwEP,
MCHelpSwEP3,MCHelpSwEP4,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwME,MCHelpSwN,MCHelpSwNa,
MCHelpSwNal,MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOP,MCHelpSwOR,
MCHelpSwOW,MCHelpSwP,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSI,
MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,
MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,
MCHelpSwXa,MCHelpSwXal,MCHelpSwY
#endif
};

Expand Down
31 changes: 29 additions & 2 deletions unrar/consio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

static MESSAGE_TYPE MsgStream=MSG_STDOUT;
static RAR_CHARSET RedirectCharset=RCH_DEFAULT;
static bool ProhibitInput=false;

const int MaxMsgSize=2*NM+2048;

Expand Down Expand Up @@ -61,6 +62,12 @@ void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset)
}


void ProhibitConsoleInput()
{
ProhibitInput=true;
}


#ifndef SILENT
static void cvt_wprintf(FILE *dest,const wchar *fmt,va_list arglist)
{
Expand Down Expand Up @@ -141,10 +148,23 @@ void eprintf(const wchar *fmt,...)


#ifndef SILENT
static void QuitIfInputProhibited()
{
// We cannot handle user prompts if -si is used to read file or archive data
// from stdin.
if (ProhibitInput)
{
mprintf(St(MStdinNoInput));
ErrHandler.Exit(RARX_FATAL);
}
}


static void GetPasswordText(wchar *Str,uint MaxLength)
{
if (MaxLength==0)
return;
QuitIfInputProhibited();
if (StdinRedirected)
getwstr(Str,MaxLength); // Read from pipe or redirected file.
else
Expand Down Expand Up @@ -190,16 +210,21 @@ bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *

while (true)
{
if (!StdinRedirected)
// if (!StdinRedirected)
if (Type==UIPASSWORD_GLOBAL)
eprintf(L"\n%s: ",St(MAskPsw));
else
eprintf(St(MAskPswFor),FileName);

wchar PlainPsw[MAXPASSWORD];
wchar PlainPsw[MAXPASSWORD+1];
GetPasswordText(PlainPsw,ASIZE(PlainPsw));
if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL)
return false;
if (wcslen(PlainPsw)>=MAXPASSWORD)
{
PlainPsw[MAXPASSWORD-1]=0;
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
}
if (!StdinRedirected && Type==UIPASSWORD_GLOBAL)
{
eprintf(St(MReAskPsw));
Expand Down Expand Up @@ -229,6 +254,8 @@ bool getwstr(wchar *str,size_t n)
// Print buffered prompt title function before waiting for input.
fflush(stderr);

QuitIfInputProhibited();

*str=0;
#if defined(_WIN_ALL)
// fgetws does not work well with non-English text in Windows,
Expand Down
1 change: 1 addition & 0 deletions unrar/consio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
void InitConsole();
void SetConsoleMsgStream(MESSAGE_TYPE MsgStream);
void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset);
void ProhibitConsoleInput();
void OutComment(const wchar *Comment,size_t Size);

#ifndef SILENT
Expand Down
10 changes: 10 additions & 0 deletions unrar/crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

#include "rar.hpp"

#ifndef SFX_MODULE
// User suggested to avoid BSD license in SFX module, so they do not need
// to include the license to SFX archive.
#define USE_SLICING
#endif

static uint crc_tables[8][256]; // Tables for Slicing-by-8.


Expand All @@ -37,6 +43,7 @@ static void InitTables()
{
InitCRC32(crc_tables[0]);

#ifdef USE_SLICING
for (uint I=0;I<256;I++) // Build additional lookup tables.
{
uint C=crc_tables[0][I];
Expand All @@ -46,6 +53,7 @@ static void InitTables()
crc_tables[J][I]=C;
}
}
#endif
}


Expand All @@ -55,6 +63,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size)
{
byte *Data=(byte *)Addr;

#ifdef USE_SLICING
// Align Data to 8 for better performance.
for (;Size>0 && ((size_t)Data & 7);Size--,Data++)
StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8);
Expand All @@ -77,6 +86,7 @@ uint CRC32(uint StartCRC,const void *Addr,size_t Size)
crc_tables[1][(byte)(NextData >> 16)] ^
crc_tables[0][(byte)(NextData >> 24)];
}
#endif

for (;Size>0;Size--,Data++) // Process left data.
StartCRC=crc_tables[0][(byte)(StartCRC^Data[0])]^(StartCRC>>8);
Expand Down
8 changes: 4 additions & 4 deletions unrar/dll.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <commctrl.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 6, 2, 1, 3796
PRODUCTVERSION 6, 2, 1, 3796
FILEVERSION 6, 10, 2, 318
PRODUCTVERSION 6, 10, 2, 318
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
{
Expand All @@ -14,8 +14,8 @@ FILETYPE VFT_APP
VALUE "CompanyName", "Alexander Roshal\0"
VALUE "ProductName", "RAR decompression library\0"
VALUE "FileDescription", "RAR decompression library\0"
VALUE "FileVersion", "6.2.1\0"
VALUE "ProductVersion", "6.2.1\0"
VALUE "FileVersion", "6.10.2\0"
VALUE "ProductVersion", "6.10.2\0"
VALUE "LegalCopyright", "Copyright \xA9 Alexander Roshal 1993-2021\0"
VALUE "OriginalFilename", "Unrar.dll\0"
}
Expand Down
2 changes: 0 additions & 2 deletions unrar/encname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ void EncodeFileName::Decode(char *Name,size_t NameSize,byte *EncName,size_t EncS
{
if (FlagBits==0)
{
if (EncPos>=EncSize)
break;
Flags=EncName[EncPos++];
FlagBits=8;
}
Expand Down
Loading

0 comments on commit 53f4b93

Please sign in to comment.