Skip to content

Commit

Permalink
Update to v6.1.2 (#29)
Browse files Browse the repository at this point in the history
* Integrate version 5.7.1 from https://www.rarlab.com/rar/unrarsrc-5.7.1.tar.gz

* Integrate version 5.7.3 from https://www.rarlab.com/rar/unrarsrc-5.7.3.tar.gz

* v5.7.4: Integrate unrar version 5.7.4

* V6.0.3 (#26)

* Integrate version 5.7.1 from https://www.rarlab.com/rar/unrarsrc-5.7.1.tar.gz

* Integrate version 5.7.3 from https://www.rarlab.com/rar/unrarsrc-5.7.3.tar.gz (#20)

* V5.7.4 => master (#22)

* Integrate version 5.7.1 from https://www.rarlab.com/rar/unrarsrc-5.7.1.tar.gz

* Integrate version 5.7.3 from https://www.rarlab.com/rar/unrarsrc-5.7.3.tar.gz

* v5.7.4: Integrate unrar version 5.7.4

* Remove some global static initializers (#23)

* Remove some global static initializers

This change removes some global static initializers we were seeing.  Replaced with helper functions that create these on demand as local statics.

* PR Feedback

Co-authored-by: Chris Davis <chrdavis@microsoft.com>

* Add unrar version 6.0.3

Co-authored-by: Chris Davis <chrisdavis@outlook.com>
Co-authored-by: Chris Davis <chrdavis@microsoft.com>

* Add unrar version 6.1.2 from rarlab.com

Co-authored-by: Chris Davis <chrisdavis@outlook.com>
Co-authored-by: Chris Davis <chrdavis@microsoft.com>
  • Loading branch information
3 people authored Nov 30, 2021
1 parent d84d613 commit 22d9aeb
Show file tree
Hide file tree
Showing 49 changed files with 663 additions and 500 deletions.
151 changes: 59 additions & 92 deletions acknow.txt
Original file line number Diff line number Diff line change
@@ -1,92 +1,59 @@
ACKNOWLEDGMENTS

* We used "Screaming Fast Galois Field Arithmetic Using Intel
SIMD Instructions" paper by James S. Plank, Kevin M. Greenan
and Ethan L. Miller to improve Reed-Solomon coding performance.
Also we are grateful to Artem Drobanov and Bulat Ziganshin
for samples and ideas allowed to make Reed-Solomon coding
more efficient.

* RAR 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.

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

---------------------------------------------------------------------------
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:

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

Copyright (c) 2004-2006 Intel Corporation.
All Rights Reserved

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with
the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ),
designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn
and Christian Winnerlein.

* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed
to significantly improve RAR compression and speed.
ACKNOWLEDGMENTS

* We used "Screaming Fast Galois Field Arithmetic Using Intel
SIMD Instructions" paper by James S. Plank, Kevin M. Greenan
and Ethan L. Miller to improve Reed-Solomon coding performance.
Also we are grateful to Artem Drobanov and Bulat Ziganshin
for samples and ideas allowed to make Reed-Solomon coding
more efficient.

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

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

* 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/

Original Intel Slicing-by-8 code is licensed under BSD License
available at http://www.opensource.org/licenses/bsd-license.html

Copyright (c) 2004-2006 Intel Corporation.
All Rights Reserved

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with
the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ),
designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn
and Christian Winnerlein.

* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed
to significantly improve RAR compression and speed.
2 changes: 1 addition & 1 deletion 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 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 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 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 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 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 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 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
Loading

0 comments on commit 22d9aeb

Please sign in to comment.