From a91dbbe9b2aba455b86d4c6df4a397f75bfc1c80 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 10 May 2013 10:03:34 +0300 Subject: Updated Unrar to v5.0.3 --- docs/Changelog.txt | 2 +- src/thirdparty/unrar/blake2s.cpp | 2 +- src/thirdparty/unrar/blake2s.hpp | 39 +++++++++++++++++++++++--------------- src/thirdparty/unrar/dll.rc | 8 ++++---- src/thirdparty/unrar/file.cpp | 9 ++++++++- src/thirdparty/unrar/filefn.cpp | 9 ++++++++- src/thirdparty/unrar/hardlinks.cpp | 4 ++-- src/thirdparty/unrar/loclang.hpp | 4 +++- src/thirdparty/unrar/rs16.cpp | 2 +- src/thirdparty/unrar/ulinks.cpp | 2 +- src/thirdparty/unrar/version.hpp | 6 +++--- src/thirdparty/unrar/win32lnk.cpp | 20 +++++++++++-------- 12 files changed, 68 insertions(+), 39 deletions(-) diff --git a/docs/Changelog.txt b/docs/Changelog.txt index 71f7e9433..5c741e511 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -14,7 +14,7 @@ Legend: and Turkish translations * Updated Little CMS to v2.5 (git d0d5b51) * Updated zlib to v1.2.8 -* Updated Unrar to v5.0.2 +* Updated Unrar to v5.0.3 * Audio Switcher improvements: - Ticket #1936, Improve the normalization algorithm to avoid huge volume variations - Use percentage for the boost setting since it is easier to understand for most people diff --git a/src/thirdparty/unrar/blake2s.cpp b/src/thirdparty/unrar/blake2s.cpp index c66b2e719..b9804654e 100644 --- a/src/thirdparty/unrar/blake2s.cpp +++ b/src/thirdparty/unrar/blake2s.cpp @@ -57,7 +57,7 @@ static inline void blake2s_increment_counter( blake2s_state *S, const uint32 inc /* init2 xors IV with input parameter block */ void blake2s_init_param( blake2s_state *S, uint32 node_offset, uint32 node_depth) { - memset( S, 0, sizeof( blake2s_state ) ); + S->init(); // Clean and set pointers. for( int i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i]; diff --git a/src/thirdparty/unrar/blake2s.hpp b/src/thirdparty/unrar/blake2s.hpp index f41662cfb..66501cc63 100644 --- a/src/thirdparty/unrar/blake2s.hpp +++ b/src/thirdparty/unrar/blake2s.hpp @@ -2,12 +2,6 @@ #ifndef _RAR_BLAKE2_ #define _RAR_BLAKE2_ -#if defined(_MSC_VER) -#define BLAKE_ALIGN(x) __declspec(align(x)) -#else -#define BLAKE_ALIGN(x) __attribute__((aligned(x))) -#endif - #define BLAKE2_DIGEST_SIZE 32 enum blake2s_constant @@ -17,18 +11,33 @@ enum blake2s_constant }; -// Alignment improves performance of non-SSE version a little -// and is required for SSE version. -BLAKE_ALIGN( 64 ) -typedef struct __blake2s_state +// Alignment to 64 improves performance of both SSE and non-SSE versions. +// Alignment to n*16 is required for SSE version, so we selected 64. +// We use the custom alignment scheme instead of __declspec(align(x)), +// because it is less compiler dependent. Also the compiler directive +// does not help if structure is a member of class allocated through +// 'new' operator. +struct blake2s_state { - uint32 h[8]; - uint32 t[2]; - uint32 f[2]; - byte buf[2 * BLAKE2S_BLOCKBYTES]; + enum { BLAKE_ALIGNMENT = 64 }; + + byte ubuf[48 + 2 * BLAKE2S_BLOCKBYTES + BLAKE_ALIGNMENT]; + + byte *buf; // byte buf[2 * BLAKE2S_BLOCKBYTES]. + uint32 *h, *t, *f; // uint32 h[8], t[2], f[2]. + size_t buflen; byte last_node; -} blake2s_state ; + + void init() + { + memset( this, 0, sizeof( blake2s_state ) ); + buf = (byte *) ALIGN_VALUE(ubuf, BLAKE_ALIGNMENT); + h = (uint32 *) (buf + 2 * BLAKE2S_BLOCKBYTES); + t = h + 8; + f = t + 2; + } +}; #ifdef RAR_SMP diff --git a/src/thirdparty/unrar/dll.rc b/src/thirdparty/unrar/dll.rc index bcf38c090..3c0c6fce4 100644 --- a/src/thirdparty/unrar/dll.rc +++ b/src/thirdparty/unrar/dll.rc @@ -2,8 +2,8 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 5, 0, 2, 851 -PRODUCTVERSION 5, 0, 2, 851 +FILEVERSION 5, 0, 3, 860 +PRODUCTVERSION 5, 0, 3, 860 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.2\0" - VALUE "ProductVersion", "5.0.2\0" + VALUE "FileVersion", "5.0.3\0" + VALUE "ProductVersion", "5.0.3\0" VALUE "LegalCopyright", "Copyright © Alexander Roshal 1993-2013\0" VALUE "OriginalFilename", "Unrar.dll\0" } diff --git a/src/thirdparty/unrar/file.cpp b/src/thirdparty/unrar/file.cpp index c67692c99..2c4de580c 100644 --- a/src/thirdparty/unrar/file.cpp +++ b/src/thirdparty/unrar/file.cpp @@ -57,14 +57,21 @@ bool File::Open(const wchar *Name,uint Mode) uint Flags=NoSequentialRead ? 0:FILE_FLAG_SEQUENTIAL_SCAN; hNewFile=CreateFile(Name,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL); + DWORD LastError; if (hNewFile==BAD_HANDLE) { + // Following CreateFile("\\?\path") call can change the last error code + // from "not found" to "access denied" for relative paths like "..\path". + // But we need the correct "not found" code to create a new archive + // if existing one is not found. So we preserve the code here. + LastError=GetLastError(); + wchar LongName[NM]; if (GetWinLongPath(Name,LongName,ASIZE(LongName))) hNewFile=CreateFile(LongName,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL); } - if (hNewFile==BAD_HANDLE && GetLastError()==ERROR_FILE_NOT_FOUND) + if (hNewFile==BAD_HANDLE && LastError==ERROR_FILE_NOT_FOUND) ErrorType=FILE_NOTFOUND; #else int flags=UpdateMode ? O_RDWR:(WriteMode ? O_WRONLY:O_RDONLY); diff --git a/src/thirdparty/unrar/filefn.cpp b/src/thirdparty/unrar/filefn.cpp index d09f50af5..4dd77f80c 100644 --- a/src/thirdparty/unrar/filefn.cpp +++ b/src/thirdparty/unrar/filefn.cpp @@ -4,7 +4,7 @@ MKDIR_CODE MakeDir(const wchar *Name,bool SetAttr,uint Attr) { #ifdef _WIN_ALL BOOL RetCode=CreateDirectory(Name,NULL); - if (RetCode==0) + if (RetCode==0 && !FileExist(Name)) { wchar LongName[NM]; if (GetWinLongPath(Name,LongName,ASIZE(LongName))) @@ -57,6 +57,13 @@ bool CreatePath(const wchar *Path,bool SkipLastName) // path in Windows or Windows in Unix. if (IsPathDiv(*s)) { +#ifdef _WIN_ALL + // We must not attempt to create "D:" directory, because first + // CreateDirectory will fail, so we'll use \\?\D:, which forces Wine + // to create "D:" directory. + if (s==Path+2 && Path[1]==':') + continue; +#endif wcsncpy(DirName,Path,s-Path); DirName[s-Path]=0; diff --git a/src/thirdparty/unrar/hardlinks.cpp b/src/thirdparty/unrar/hardlinks.cpp index f783e1f47..f41d3e8ac 100644 --- a/src/thirdparty/unrar/hardlinks.cpp +++ b/src/thirdparty/unrar/hardlinks.cpp @@ -8,7 +8,7 @@ bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) bool Success=CreateHardLink(NameNew,NameExisting,NULL)!=0; if (!Success) { - ErrHandler.CreateErrorMsg(NameNew); + Log(NULL,St(MErrCreateLnkH),NameNew); ErrHandler.SysErrMsg(); ErrHandler.SetErrorCode(RARX_CREATE); } @@ -22,7 +22,7 @@ bool ExtractHardlink(wchar *NameNew,wchar *NameExisting,size_t NameExistingSize) bool Success=link(NameExistingA,NameNewA)==0; if (!Success) { - ErrHandler.CreateErrorMsg(NameNew); + Log(NULL,St(MErrCreateLnkH),NameNew); ErrHandler.SysErrMsg(); ErrHandler.SetErrorCode(RARX_CREATE); } diff --git a/src/thirdparty/unrar/loclang.hpp b/src/thirdparty/unrar/loclang.hpp index 2d84c44ac..6941a3189 100644 --- a/src/thirdparty/unrar/loclang.hpp +++ b/src/thirdparty/unrar/loclang.hpp @@ -309,7 +309,6 @@ #define MOwnersBroken "\nERROR: %s group and owner data are corrupt\n" #define MSetOwnersError "\nWARNING: Cannot set %s owner and group\n" #define MErrLnkRead "\nWARNING: Cannot read symbolic link %s" -#define MErrCreateLnk "\nWARNING: Cannot create link %s" #define MSymLinkExists "\nWARNING: Symbolic link %s already exists" #define MAskRetryCreate "\nCannot create %s. Retry ?" #define MListMACHead1 "\n Mac OS file type: %c%c%c%c ; " @@ -382,3 +381,6 @@ #define MCopyError "\nCannot copy %s to %s." #define MCopyErrorHint "\nYou need to unpack the entire archive to create file copy entries." #define MCopyingData "\nCopying data" +#define MErrCreateLnkS "\nCannot create symbolic link %s" +#define MErrCreateLnkH "\nCannot create hard link %s" +#define MNeedAdmin "\nYou may need to run RAR as administrator" diff --git a/src/thirdparty/unrar/rs16.cpp b/src/thirdparty/unrar/rs16.cpp index 2e3f20da0..082ab83f4 100644 --- a/src/thirdparty/unrar/rs16.cpp +++ b/src/thirdparty/unrar/rs16.cpp @@ -344,7 +344,7 @@ bool RSCoder16::SSE_UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte __m128i Low4Mask=_mm_set1_epi8(0xf); // 0f0f0f0f...0f0f __m128i High4Mask=_mm_slli_epi16(Low4Mask,4); // f0f0f0f0...f0f0 - for (; Pos<=BlockSize-2*sizeof(__m128i); Pos+=2*sizeof(__m128i)) + for (; Pos+2*sizeof(__m128i)<=BlockSize; Pos+=2*sizeof(__m128i)) { // We process two 128 bit chunks of source data at once. __m128i *D=(__m128i *)(Data+Pos); diff --git a/src/thirdparty/unrar/ulinks.cpp b/src/thirdparty/unrar/ulinks.cpp index 7a309eedc..5b67bbdfa 100644 --- a/src/thirdparty/unrar/ulinks.cpp +++ b/src/thirdparty/unrar/ulinks.cpp @@ -12,7 +12,7 @@ static bool UnixSymlink(const char *Target,const wchar *LinkName) Log(NULL,St(MSymLinkExists),LinkName); else { - Log(NULL,St(MErrCreateLnk),LinkName); + Log(NULL,St(MErrCreateLnkS),LinkName); ErrHandler.SetErrorCode(RARX_WARNING); } mprintf(L" "); // Provide space for "OK" message. diff --git a/src/thirdparty/unrar/version.hpp b/src/thirdparty/unrar/version.hpp index 4687491c1..0e53da493 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 2 -#define RARVER_DAY 30 -#define RARVER_MONTH 4 +#define RARVER_BETA 3 +#define RARVER_DAY 9 +#define RARVER_MONTH 5 #define RARVER_YEAR 2013 diff --git a/src/thirdparty/unrar/win32lnk.cpp b/src/thirdparty/unrar/win32lnk.cpp index cfb552f7e..4a2223bc1 100644 --- a/src/thirdparty/unrar/win32lnk.cpp +++ b/src/thirdparty/unrar/win32lnk.cpp @@ -36,8 +36,8 @@ void GetReparsePoint(const wchar *Name,FileHeader *hd) PrivSet=true; } - WIN32_FIND_DATAW FindData; - HANDLE hFind=FindFirstFileW(Name,&FindData); + WIN32_FIND_DATA FindData; + HANDLE hFind=FindFirstFile(Name,&FindData); if (hFind==INVALID_HANDLE_VALUE) return; FindClose(hFind); @@ -47,7 +47,7 @@ void GetReparsePoint(const wchar *Name,FileHeader *hd) FindData.dwReserved0!=IO_REPARSE_TAG_SYMLINK) return; - HANDLE hFile=CreateFileW( + HANDLE hFile=CreateFile( Name,FILE_READ_EA,FILE_SHARE_READ,NULL,OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OPEN_REPARSE_POINT,NULL); if (hFile==INVALID_HANDLE_VALUE) @@ -109,6 +109,8 @@ bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd) if (!PrivSet) { SetPrivilege(SE_RESTORE_NAME); + // Not sure if we really need it, but let's request anyway. + SetPrivilege(SE_CREATE_SYMBOLIC_LINK_NAME); PrivSet=true; } @@ -118,12 +120,12 @@ bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd) // Unix symlinks do not have their own 'directory' attribute. if (hd->Dir || hd->DirTarget) { - if (!CreateDirectoryW(Name,NULL)) + if (!CreateDirectory(Name,NULL)) return false; } else { - HANDLE hFile=CreateFileW(Name,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); + HANDLE hFile=CreateFile(Name,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); if (hFile == INVALID_HANDLE_VALUE) return false; CloseHandle(hFile); @@ -209,14 +211,16 @@ bool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd) rdb->ReparseDataLength,NULL,0,&Returned,NULL)) { CloseHandle(hFile); - ErrHandler.CreateErrorMsg(Name); + Log(NULL,St(MErrCreateLnkS),Name); + if (GetLastError()==ERROR_PRIVILEGE_NOT_HELD) + Log(NULL,St(MNeedAdmin)); ErrHandler.SysErrMsg(); ErrHandler.SetErrorCode(RARX_CREATE); if (hd->Dir) - RemoveDirectoryW(Name); + RemoveDirectory(Name); else - DeleteFileW(Name); + DeleteFile(Name); return false; } File LinkFile; -- cgit v1.2.3