Skip to content

Commit 22d9aeb

Browse files
aawcchrdavisChris Davis
authored
Update to v6.1.2 (#29)
* 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 <[email protected]> * Add unrar version 6.0.3 Co-authored-by: Chris Davis <[email protected]> Co-authored-by: Chris Davis <[email protected]> * Add unrar version 6.1.2 from rarlab.com Co-authored-by: Chris Davis <[email protected]> Co-authored-by: Chris Davis <[email protected]>
1 parent d84d613 commit 22d9aeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+663
-500
lines changed

acknow.txt

Lines changed: 59 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,59 @@
1-
ACKNOWLEDGMENTS
2-
3-
* We used "Screaming Fast Galois Field Arithmetic Using Intel
4-
SIMD Instructions" paper by James S. Plank, Kevin M. Greenan
5-
and Ethan L. Miller to improve Reed-Solomon coding performance.
6-
Also we are grateful to Artem Drobanov and Bulat Ziganshin
7-
for samples and ideas allowed to make Reed-Solomon coding
8-
more efficient.
9-
10-
* RAR text compression algorithm is based on Dmitry Shkarin PPMII
11-
and Dmitry Subbotin carryless rangecoder public domain source code.
12-
You may find it in ftp.elf.stuba.sk/pub/pc/pack.
13-
14-
* RAR encryption includes parts of code from Szymon Stefanek
15-
and Brian Gladman AES implementations also as Steve Reid SHA-1 source.
16-
17-
---------------------------------------------------------------------------
18-
Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK.
19-
All rights reserved.
20-
21-
LICENSE TERMS
22-
23-
The free distribution and use of this software in both source and binary
24-
form is allowed (with or without changes) provided that:
25-
26-
1. distributions of this source code include the above copyright
27-
notice, this list of conditions and the following disclaimer;
28-
29-
2. distributions in binary form include the above copyright
30-
notice, this list of conditions and the following disclaimer
31-
in the documentation and/or other associated materials;
32-
33-
3. the copyright holder's name is not used to endorse products
34-
built using this software without specific written permission.
35-
36-
ALTERNATIVELY, provided that this notice is retained in full, this product
37-
may be distributed under the terms of the GNU General Public License (GPL),
38-
in which case the provisions of the GPL apply INSTEAD OF those given above.
39-
40-
DISCLAIMER
41-
42-
This software is provided 'as is' with no explicit or implied warranties
43-
in respect of its properties, including, but not limited to, correctness
44-
and/or fitness for purpose.
45-
---------------------------------------------------------------------------
46-
47-
Source code of this package also as other cryptographic technology
48-
and computing project related links are available on Brian Gladman's
49-
web site: http://www.gladman.me.uk
50-
51-
* RAR uses CRC32 function based on Intel Slicing-by-8 algorithm.
52-
Original Intel Slicing-by-8 code is available here:
53-
54-
https://sourceforge.net/projects/slicing-by-8/
55-
56-
Original Intel Slicing-by-8 code is licensed under BSD License
57-
available at http://www.opensource.org/licenses/bsd-license.html
58-
59-
Copyright (c) 2004-2006 Intel Corporation.
60-
All Rights Reserved
61-
62-
Redistribution and use in source and binary forms, with or without
63-
modification, are permitted provided that the following conditions
64-
are met:
65-
66-
Redistributions of source code must retain the above copyright notice,
67-
this list of conditions and the following disclaimer.
68-
69-
Redistributions in binary form must reproduce the above copyright
70-
notice, this list of conditions and the following disclaimer
71-
in the documentation and/or other materials provided with
72-
the distribution.
73-
74-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
75-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
76-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
77-
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
78-
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
79-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
80-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
81-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
82-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
83-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
84-
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
85-
SUCH DAMAGE.
86-
87-
* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ),
88-
designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn
89-
and Christian Winnerlein.
90-
91-
* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed
92-
to significantly improve RAR compression and speed.
1+
ACKNOWLEDGMENTS
2+
3+
* We used "Screaming Fast Galois Field Arithmetic Using Intel
4+
SIMD Instructions" paper by James S. Plank, Kevin M. Greenan
5+
and Ethan L. Miller to improve Reed-Solomon coding performance.
6+
Also we are grateful to Artem Drobanov and Bulat Ziganshin
7+
for samples and ideas allowed to make Reed-Solomon coding
8+
more efficient.
9+
10+
* RAR4 text compression algorithm is based on Dmitry Shkarin PPMII
11+
and Dmitry Subbotin carryless rangecoder public domain source code.
12+
You can find it in ftp.elf.stuba.sk/pub/pc/pack.
13+
14+
* RAR encryption includes parts of public domain code
15+
from Szymon Stefanek AES and Steve Reid SHA-1 implementations.
16+
17+
* With exception of SFX modules, RAR uses CRC32 function based
18+
on Intel Slicing-by-8 algorithm. Original Intel Slicing-by-8 code
19+
is available here:
20+
21+
https://sourceforge.net/projects/slicing-by-8/
22+
23+
Original Intel Slicing-by-8 code is licensed under BSD License
24+
available at http://www.opensource.org/licenses/bsd-license.html
25+
26+
Copyright (c) 2004-2006 Intel Corporation.
27+
All Rights Reserved
28+
29+
Redistribution and use in source and binary forms, with or without
30+
modification, are permitted provided that the following conditions
31+
are met:
32+
33+
Redistributions of source code must retain the above copyright notice,
34+
this list of conditions and the following disclaimer.
35+
36+
Redistributions in binary form must reproduce the above copyright
37+
notice, this list of conditions and the following disclaimer
38+
in the documentation and/or other materials provided with
39+
the distribution.
40+
41+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
42+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
43+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
44+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
45+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
48+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
49+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52+
SUCH DAMAGE.
53+
54+
* RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ),
55+
designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn
56+
and Christian Winnerlein.
57+
58+
* Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed
59+
to significantly improve RAR compression and speed.

archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool Archive::IsArchive(bool EnableBroken)
231231
// first file header to set "comment" flag when reading service header.
232232
// Unless we are in silent mode, we need to know about presence of comment
233233
// immediately after IsArchive call.
234-
if (HeadersLeft && (!SilentOpen || !Encrypted))
234+
if (HeadersLeft && (!SilentOpen || !Encrypted) && IsSeekable())
235235
{
236236
int64 SavePos=Tell();
237237
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;

arcread.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,13 @@ size_t Archive::ReadHeader50()
558558
return 0;
559559
#else
560560

561+
if (Cmd->SkipEncrypted)
562+
{
563+
uiMsg(UIMSG_SKIPENCARC,FileName);
564+
FailedHeaderDecryption=true; // Suppress error messages and quit quietly.
565+
return 0;
566+
}
567+
561568
byte HeadersInitV[SIZE_INITV];
562569
if (Read(HeadersInitV,SIZE_INITV)!=SIZE_INITV)
563570
{
@@ -876,7 +883,12 @@ size_t Archive::ReadHeader50()
876883
// code to shell extension, which is not done now.
877884
if (!FileBlock && hd->CmpName(SUBHEAD_TYPE_RR) && hd->SubData.Size()>0)
878885
{
879-
RecoveryPercent=hd->SubData[0];
886+
// It is stored as a single byte up to RAR 6.02 and as vint since
887+
// 6.10, where we extended the maximum RR size from 99% to 1000%.
888+
RawRead RawPercent;
889+
RawPercent.Read(&hd->SubData[0],hd->SubData.Size());
890+
RecoveryPercent=(int)RawPercent.GetV();
891+
880892
RSBlockHeader Header;
881893
GetRRInfo(this,&Header);
882894
RecoverySize=Header.RecSectionSize*Header.RecCount;

cmddata.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ void CommandData::ParseArg(wchar *Arg)
108108
// 'S' can contain SFX name, which case is important in Unix.
109109
if (*Command!='I' && *Command!='S')
110110
wcsupper(Command);
111+
if (*Command=='P') // Enforce -idq for print command.
112+
{
113+
MsgStream=MSG_ERRONLY;
114+
SetConsoleMsgStream(MSG_ERRONLY);
115+
}
111116
}
112117
else
113118
if (*ArcName==0)
@@ -373,6 +378,9 @@ void CommandData::ProcessSwitch(const wchar *Switch)
373378
case '3':
374379
ExclPath=EXCL_ABSPATH;
375380
break;
381+
case '4':
382+
wcsncpyz(ExclArcPath,Switch+3,ASIZE(ExclArcPath));
383+
break;
376384
}
377385
break;
378386
default:
@@ -399,6 +407,8 @@ void CommandData::ProcessSwitch(const wchar *Switch)
399407
EncryptHeaders=true;
400408
if (Switch[2]!=0)
401409
{
410+
if (wcslen(Switch+2)>=MAXPASSWORD)
411+
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
402412
Password.Set(Switch+2);
403413
cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
404414
}
@@ -561,6 +571,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
561571
break;
562572
case 'D':
563573
break;
574+
case 'E':
575+
if (toupperw(Switch[2])=='S' && Switch[3]==0)
576+
SkipEncrypted=true;
577+
break;
564578
case 'S':
565579
{
566580
wchar StoreNames[1024];
@@ -648,6 +662,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
648662
AllowIncompatNames=true;
649663
break;
650664
#endif
665+
case 'P':
666+
wcsncpyz(ExtrPath,Switch+2,ASIZE(ExtrPath));
667+
AddEndSlash(ExtrPath,ASIZE(ExtrPath));
668+
break;
651669
case 'R':
652670
Overwrite=OVERWRITE_AUTORENAME;
653671
break;
@@ -672,6 +690,8 @@ void CommandData::ProcessSwitch(const wchar *Switch)
672690
}
673691
else
674692
{
693+
if (wcslen(Switch+1)>=MAXPASSWORD)
694+
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
675695
Password.Set(Switch+1);
676696
cleandata((void *)Switch,wcslen(Switch)*sizeof(Switch[0]));
677697
}
@@ -752,6 +772,10 @@ void CommandData::ProcessSwitch(const wchar *Switch)
752772
case 'D':
753773
Solid|=SOLID_VOLUME_DEPENDENT;
754774
break;
775+
case 'I':
776+
ProhibitConsoleInput();
777+
wcsncpyz(UseStdin,Switch[2] ? Switch+2:L"stdin",ASIZE(UseStdin));
778+
break;
755779
case 'L':
756780
if (IsDigit(Switch[2]))
757781
FileSizeLess=atoilw(Switch+2);
@@ -935,7 +959,7 @@ void CommandData::ProcessCommand()
935959
wcsncpyz(ArcName,Name,ASIZE(ArcName));
936960
}
937961

938-
if (wcschr(L"AFUMD",*Command)==NULL)
962+
if (wcschr(L"AFUMD",*Command)==NULL && *UseStdin==0)
939963
{
940964
if (GenerateArcName)
941965
{

cmddata.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class CommandData:public RAROptions
5050
bool GetArcName(wchar *Name,int MaxSize);
5151
bool CheckWinSize();
5252

53-
int GetRecoverySize(const wchar *Str,int DefSize);
53+
int GetRecoverySize(const wchar *CmdStr,const wchar *Value,int DefSize);
5454

5555
#ifndef SFX_MODULE
5656
void ReportWrongSwitches(RARFORMAT Format);

cmdfilter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ bool CommandData::TimeCheck(RarTime &ftm,RarTime &ftc,RarTime &fta)
262262
// Return 'true' if we need to exclude the file from processing.
263263
bool CommandData::SizeCheck(int64 Size)
264264
{
265+
if (Size==INT64NDF) // If called from archive formats like bzip2, not storing the file size.
266+
return false;
265267
if (FileSizeLess!=INT64NDF && Size>=FileSizeLess)
266268
return true;
267269
if (FileSizeMore!=INT64NDF && Size<=FileSizeMore)

cmdmix.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ void CommandData::OutHelp(RAR_EXIT ExitCode)
6161
MUNRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdE,MCHelpCmdL,
6262
MCHelpCmdP,MCHelpCmdT,MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm,
6363
MCHelpSwAT,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,MCHelpSwAI,MCHelpSwAP,
64-
MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,
65-
MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
66-
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
67-
MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
68-
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSL,MCHelpSwSM,
69-
MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,
70-
MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,
71-
MCHelpSwY
64+
MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,MCHelpSwDH,MCHelpSwEP,
65+
MCHelpSwEP3,MCHelpSwEP4,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
66+
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwME,MCHelpSwN,MCHelpSwNa,
67+
MCHelpSwNal,MCHelpSwO,MCHelpSwOC,MCHelpSwOL,MCHelpSwOP,MCHelpSwOR,
68+
MCHelpSwOW,MCHelpSwP,MCHelpSwR,MCHelpSwRI,MCHelpSwSC,MCHelpSwSI,
69+
MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,
70+
MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,MCHelpSwX,
71+
MCHelpSwXa,MCHelpSwXal,MCHelpSwY
7272
#endif
7373
};
7474

consio.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
55
static RAR_CHARSET RedirectCharset=RCH_DEFAULT;
6+
static bool ProhibitInput=false;
67

78
const int MaxMsgSize=2*NM+2048;
89

@@ -61,6 +62,12 @@ void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset)
6162
}
6263

6364

65+
void ProhibitConsoleInput()
66+
{
67+
ProhibitInput=true;
68+
}
69+
70+
6471
#ifndef SILENT
6572
static void cvt_wprintf(FILE *dest,const wchar *fmt,va_list arglist)
6673
{
@@ -141,10 +148,23 @@ void eprintf(const wchar *fmt,...)
141148

142149

143150
#ifndef SILENT
151+
static void QuitIfInputProhibited()
152+
{
153+
// We cannot handle user prompts if -si is used to read file or archive data
154+
// from stdin.
155+
if (ProhibitInput)
156+
{
157+
mprintf(St(MStdinNoInput));
158+
ErrHandler.Exit(RARX_FATAL);
159+
}
160+
}
161+
162+
144163
static void GetPasswordText(wchar *Str,uint MaxLength)
145164
{
146165
if (MaxLength==0)
147166
return;
167+
QuitIfInputProhibited();
148168
if (StdinRedirected)
149169
getwstr(Str,MaxLength); // Read from pipe or redirected file.
150170
else
@@ -190,16 +210,21 @@ bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *
190210

191211
while (true)
192212
{
193-
if (!StdinRedirected)
213+
// if (!StdinRedirected)
194214
if (Type==UIPASSWORD_GLOBAL)
195215
eprintf(L"\n%s: ",St(MAskPsw));
196216
else
197217
eprintf(St(MAskPswFor),FileName);
198218

199-
wchar PlainPsw[MAXPASSWORD];
219+
wchar PlainPsw[MAXPASSWORD+1];
200220
GetPasswordText(PlainPsw,ASIZE(PlainPsw));
201221
if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL)
202222
return false;
223+
if (wcslen(PlainPsw)>=MAXPASSWORD)
224+
{
225+
PlainPsw[MAXPASSWORD-1]=0;
226+
uiMsg(UIERROR_TRUNCPSW,MAXPASSWORD-1);
227+
}
203228
if (!StdinRedirected && Type==UIPASSWORD_GLOBAL)
204229
{
205230
eprintf(St(MReAskPsw));
@@ -229,6 +254,8 @@ bool getwstr(wchar *str,size_t n)
229254
// Print buffered prompt title function before waiting for input.
230255
fflush(stderr);
231256

257+
QuitIfInputProhibited();
258+
232259
*str=0;
233260
#if defined(_WIN_ALL)
234261
// fgetws does not work well with non-English text in Windows,

consio.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
void InitConsole();
55
void SetConsoleMsgStream(MESSAGE_TYPE MsgStream);
66
void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset);
7+
void ProhibitConsoleInput();
78
void OutComment(const wchar *Comment,size_t Size);
89

910
#ifndef SILENT

0 commit comments

Comments
 (0)