diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2013-11-12 19:14:56 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2013-11-17 15:45:25 +0400 |
commit | 3682dd164d4ad1229d5feee50af2beff6788d06d (patch) | |
tree | 279fb166149619e43783ba575de2438ae818f933 /src/thirdparty/unrar | |
parent | aa405a49f960c394eb623d291371ae01a4fe772e (diff) |
Update Unrar to v5.0.0.13.
Diffstat (limited to 'src/thirdparty/unrar')
-rw-r--r-- | src/thirdparty/unrar/archive.cpp | 23 | ||||
-rw-r--r-- | src/thirdparty/unrar/dll.cpp | 15 | ||||
-rw-r--r-- | src/thirdparty/unrar/dll.hpp | 2 | ||||
-rw-r--r-- | src/thirdparty/unrar/dll.rc | 8 | ||||
-rw-r--r-- | src/thirdparty/unrar/errhnd.cpp | 6 | ||||
-rw-r--r-- | src/thirdparty/unrar/extract.cpp | 13 | ||||
-rw-r--r-- | src/thirdparty/unrar/extract.hpp | 2 | ||||
-rw-r--r-- | src/thirdparty/unrar/file.cpp | 49 | ||||
-rw-r--r-- | src/thirdparty/unrar/pathfn.cpp | 4 | ||||
-rw-r--r-- | src/thirdparty/unrar/version.hpp | 8 | ||||
-rw-r--r-- | src/thirdparty/unrar/win32lnk.cpp | 1 |
11 files changed, 74 insertions, 57 deletions
diff --git a/src/thirdparty/unrar/archive.cpp b/src/thirdparty/unrar/archive.cpp index 5b7ef7a67..ab33b2d01 100644 --- a/src/thirdparty/unrar/archive.cpp +++ b/src/thirdparty/unrar/archive.cpp @@ -49,6 +49,7 @@ Archive::Archive(RAROptions *InitCmd) NewArchive=false; SilentOpen=false; + } @@ -201,6 +202,15 @@ bool Archive::IsArchive(bool EnableBroken) else MarkHead.HeadSize=SIZEOF_MARKHEAD3; +#ifdef RARDLL + // If callback function is not set, we cannot get the password, + // so we skip the initial header processing for encrypted header archive. + // It leads to skipped archive comment, but the rest of archive data + // is processed correctly. + if (Cmd->Callback==NULL) + SilentOpen=true; +#endif + // Skip the archive encryption header if any and read the main header. while (ReadHeader()!=0) { @@ -244,15 +254,6 @@ bool Archive::IsArchive(bool EnableBroken) } */ -#ifdef RARDLL - // If callback function is not set, we cannot get the password, - // so we skip the initial header processing for encrypted header archive. - // It leads to skipped archive comment, but the rest of archive data - // is processed correctly. - if (Cmd->Callback==NULL) - SilentOpen=true; -#endif - MainComment=MainHead.CommentInHeader; // If we process non-encrypted archive or can request a password, @@ -271,10 +272,10 @@ bool Archive::IsArchive(bool EnableBroken) { HEADER_TYPE HeaderType=GetHeaderType(); if (HeaderType==HEAD_SERVICE) - FirstVolume=!SubHead.SplitBefore; + FirstVolume=Volume && !SubHead.SplitBefore; else { - FirstVolume=HeaderType==HEAD_FILE && !FileHead.SplitBefore; + FirstVolume=Volume && HeaderType==HEAD_FILE && !FileHead.SplitBefore; break; } SeekToNext(); diff --git a/src/thirdparty/unrar/dll.cpp b/src/thirdparty/unrar/dll.cpp index f8c598270..20e5437e8 100644 --- a/src/thirdparty/unrar/dll.cpp +++ b/src/thirdparty/unrar/dll.cpp @@ -73,7 +73,16 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r) } if (!Data->Arc.IsArchive(false)) { - r->OpenResult=Data->Cmd.DllError!=0 ? Data->Cmd.DllError:ERAR_BAD_ARCHIVE; + if (Data->Cmd.DllError!=0) + r->OpenResult=Data->Cmd.DllError; + else + { + RAR_EXIT ErrCode=ErrHandler.GetErrorCode(); + if (ErrCode!=RARX_SUCCESS && ErrCode!=RARX_WARNING) + r->OpenResult=RarErrorToDll(ErrCode); + else + r->OpenResult=ERAR_BAD_ARCHIVE; + } delete Data; return NULL; } @@ -197,7 +206,7 @@ int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *D) else return Code; } - wcsncpy(D->ArcNameW,hd->FileName,ASIZE(D->ArcNameW)); + wcsncpy(D->ArcNameW,Data->Arc.FileName,ASIZE(D->ArcNameW)); WideToChar(D->ArcNameW,D->ArcName,ASIZE(D->ArcName)); wcsncpy(D->FileNameW,hd->FileName,ASIZE(D->FileNameW)); @@ -419,6 +428,8 @@ static int RarErrorToDll(RAR_EXIT ErrCode) return ERAR_ECREATE; case RARX_MEMORY: return ERAR_NO_MEMORY; + case RARX_BADPWD: + return ERAR_BAD_PASSWORD; case RARX_SUCCESS: return ERAR_SUCCESS; // 0. default: diff --git a/src/thirdparty/unrar/dll.hpp b/src/thirdparty/unrar/dll.hpp index 2c5868b8a..9fd560939 100644 --- a/src/thirdparty/unrar/dll.hpp +++ b/src/thirdparty/unrar/dll.hpp @@ -17,6 +17,8 @@ #define ERAR_SMALL_BUF 20 #define ERAR_UNKNOWN 21 #define ERAR_MISSING_PASSWORD 22 +#define ERAR_EREFERENCE 23 +#define ERAR_BAD_PASSWORD 24 #define RAR_OM_LIST 0 #define RAR_OM_EXTRACT 1 diff --git a/src/thirdparty/unrar/dll.rc b/src/thirdparty/unrar/dll.rc index 6a91d1a9a..dbe1603f4 100644 --- a/src/thirdparty/unrar/dll.rc +++ b/src/thirdparty/unrar/dll.rc @@ -2,8 +2,8 @@ #include <commctrl.h>
VS_VERSION_INFO VERSIONINFO
-FILEVERSION 5, 0, 100, 965
-PRODUCTVERSION 5, 0, 100, 965
+FILEVERSION 5, 1, 1, 1047
+PRODUCTVERSION 5, 1, 1, 1047
FILEOS VOS__WINDOWS32
FILETYPE VFT_APP
{
@@ -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", "5.0.0\0"
- VALUE "ProductVersion", "5.0.0\0"
+ VALUE "FileVersion", "5.1.1\0"
+ VALUE "ProductVersion", "5.1.1\0"
VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2013\0"
VALUE "OriginalFilename", "Unrar.dll\0"
}
diff --git a/src/thirdparty/unrar/errhnd.cpp b/src/thirdparty/unrar/errhnd.cpp index a47d1c16c..fc7819f58 100644 --- a/src/thirdparty/unrar/errhnd.cpp +++ b/src/thirdparty/unrar/errhnd.cpp @@ -254,6 +254,10 @@ void ErrorHandler::SetErrorCode(RAR_EXIT Code) if (ExitCode==RARX_SUCCESS) ExitCode=Code; break; + case RARX_CRC: + if (ExitCode!=RARX_BADPWD) + ExitCode=Code; + break; case RARX_FATAL: if (ExitCode==RARX_SUCCESS || ExitCode==RARX_WARNING) ExitCode=RARX_FATAL; @@ -338,7 +342,7 @@ void ErrorHandler::Throw(RAR_EXIT Code) if (Code!=RARX_SUCCESS && Code!=RARX_USERERROR) mprintf(L"\n%s\n",St(MProgAborted)); #endif - ErrHandler.SetErrorCode(Code); + SetErrorCode(Code); throw Code; } diff --git a/src/thirdparty/unrar/extract.cpp b/src/thirdparty/unrar/extract.cpp index d6d600019..6d36112b6 100644 --- a/src/thirdparty/unrar/extract.cpp +++ b/src/thirdparty/unrar/extract.cpp @@ -555,7 +555,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS if (Type==FSREDIR_HARDLINK)
LinkSuccess=ExtractHardlink(DestFileName,NameExisting,ASIZE(NameExisting));
else
- LinkSuccess=ExtractFileCopy(CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting));
+ LinkSuccess=ExtractFileCopy(Cmd,CurFile,Arc.FileName,DestFileName,NameExisting,ASIZE(NameExisting));
}
else
if (Type==FSREDIR_UNIXSYMLINK || Type==FSREDIR_WINSYMLINK || Type==FSREDIR_JUNCTION)
@@ -615,12 +615,12 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS bool BrokenFile=false;
// Checksum is not calculated in skip solid mode for performance reason.
- if (!SkipSolid)
+ if (!SkipSolid && ShowChecksum)
{
if (!WrongPassword && ValidCRC)
{
#ifndef GUI
- if (Command!='P' && Command!='I' && ShowChecksum)
+ if (Command!='P' && Command!='I')
mprintf(L"%s%s ",Cmd->DisablePercentage ? L" ":L"\b\b\b\b\b ",
Arc.FileHead.FileHash.Type==HASH_NONE ? L" ?":St(MOk));
#endif
@@ -706,7 +706,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderS void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize)
{
- Array<byte> Buffer(0x100000);
+ Array<byte> Buffer(0x40000);
while (1)
{
uint Code=DataIO.UnpRead(&Buffer[0],Buffer.Size());
@@ -720,7 +720,7 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize) }
-bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
+bool CmdExtract::ExtractFileCopy(CommandData *Cmd,File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize)
{
#ifdef _WIN_ALL
UnixSlashToDos(NameExisting,NameExisting,NameExistingSize);
@@ -733,6 +733,9 @@ bool CmdExtract::ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar * ErrHandler.OpenErrorMsg(ArcName,NameExisting);
Log(ArcName,St(MCopyError),NameExisting,NameNew);
Log(ArcName,St(MCopyErrorHint));
+#ifdef RARDLL
+ Cmd->DllError=ERAR_EREFERENCE;
+#endif
return false;
}
diff --git a/src/thirdparty/unrar/extract.hpp b/src/thirdparty/unrar/extract.hpp index 11eb2e498..817bf4d6f 100644 --- a/src/thirdparty/unrar/extract.hpp +++ b/src/thirdparty/unrar/extract.hpp @@ -7,7 +7,7 @@ class CmdExtract { private: EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd); - bool ExtractFileCopy(File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize); + bool ExtractFileCopy(CommandData *Cmd,File &New,wchar *ArcName,wchar *NameNew,wchar *NameExisting,size_t NameExistingSize); void ExtrPrepareName(CommandData *Cmd,Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize); #ifdef RARDLL bool ExtrDllGetPassword(CommandData *Cmd); diff --git a/src/thirdparty/unrar/file.cpp b/src/thirdparty/unrar/file.cpp index 4bfafe05a..7b8c2cfc8 100644 --- a/src/thirdparty/unrar/file.cpp +++ b/src/thirdparty/unrar/file.cpp @@ -68,7 +68,10 @@ bool File::Open(const wchar *Name,uint Mode) wchar LongName[NM]; if (GetWinLongPath(Name,LongName,ASIZE(LongName))) + { hNewFile=CreateFile(LongName,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL); + LastError=GetLastError(); + } } if (hNewFile==BAD_HANDLE && LastError==ERROR_FILE_NOT_FOUND) @@ -188,23 +191,25 @@ bool File::WCreate(const wchar *Name,uint Mode) bool File::Close() { bool Success=true; - if (HandleType!=FILE_HANDLENORMAL) - HandleType=FILE_HANDLENORMAL; - else - if (hFile!=BAD_HANDLE) + + if (hFile!=BAD_HANDLE) + { + if (!SkipClose) { - if (!SkipClose) - { #ifdef _WIN_ALL + // We use the standard system handle for stdout in Windows + // and it must not be closed here. + if (HandleType==FILE_HANDLENORMAL) Success=CloseHandle(hFile)==TRUE; #else - Success=fclose(hFile)!=EOF; + Success=fclose(hFile)!=EOF; #endif - } - hFile=BAD_HANDLE; - if (!Success && AllowExceptions) - ErrHandler.CloseError(FileName); } + hFile=BAD_HANDLE; + } + HandleType=FILE_HANDLENORMAL; + if (!Success && AllowExceptions) + ErrHandler.CloseError(FileName); return Success; } @@ -250,24 +255,16 @@ void File::Write(const void *Data,size_t Size) { if (Size==0) return; - if (HandleType!=FILE_HANDLENORMAL) - switch(HandleType) - { - case FILE_HANDLESTD: -#ifdef _WIN_ALL - hFile=GetStdHandle(STD_OUTPUT_HANDLE); -#else - hFile=stdout; -#endif - break; - case FILE_HANDLEERR: + if (HandleType==FILE_HANDLESTD) + { #ifdef _WIN_ALL - hFile=GetStdHandle(STD_ERROR_HANDLE); + hFile=GetStdHandle(STD_OUTPUT_HANDLE); #else - hFile=stderr; + // Cannot use the standard stdout here, because it already has wide orientation. + if (hFile==BAD_HANDLE) + hFile=fdopen(dup(1),"w"); // Open new stdout stream. #endif - break; - } + } while (1) { bool Success=false; diff --git a/src/thirdparty/unrar/pathfn.cpp b/src/thirdparty/unrar/pathfn.cpp index 080996297..1a85d548c 100644 --- a/src/thirdparty/unrar/pathfn.cpp +++ b/src/thirdparty/unrar/pathfn.cpp @@ -424,7 +424,7 @@ void MakeNameUsable(char *Name,bool Extended) #ifndef _UNIX if (s-Name>1 && *s==':') *s='_'; - if ((*s==' ' || *s=='.') && IsPathDiv(s[1])) + if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1])) *s='_'; #endif } @@ -440,7 +440,7 @@ void MakeNameUsable(wchar *Name,bool Extended) #ifndef _UNIX if (s-Name>1 && *s==':') *s='_'; - if ((*s==' ' || *s=='.') && IsPathDiv(s[1])) + if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1])) *s='_'; #endif } diff --git a/src/thirdparty/unrar/version.hpp b/src/thirdparty/unrar/version.hpp index 183d26e59..ce7a3a6f0 100644 --- a/src/thirdparty/unrar/version.hpp +++ b/src/thirdparty/unrar/version.hpp @@ -1,6 +1,6 @@ #define RARVER_MAJOR 5 -#define RARVER_MINOR 0 -#define RARVER_BETA 0 -#define RARVER_DAY 22 -#define RARVER_MONTH 8 +#define RARVER_MINOR 1 +#define RARVER_BETA 1 +#define RARVER_DAY 12 +#define RARVER_MONTH 11 #define RARVER_YEAR 2013 diff --git a/src/thirdparty/unrar/win32lnk.cpp b/src/thirdparty/unrar/win32lnk.cpp index 4a2223bc1..989e060a7 100644 --- a/src/thirdparty/unrar/win32lnk.cpp +++ b/src/thirdparty/unrar/win32lnk.cpp @@ -53,7 +53,6 @@ void GetReparsePoint(const wchar *Name,FileHeader *hd) if (hFile==INVALID_HANDLE_VALUE) { ErrHandler.OpenErrorMsg(NULL,Name); - ErrHandler.SysErrMsg(); ErrHandler.SetErrorCode(RARX_OPEN); return; } |