Skip to content

Commit

Permalink
Various 7-Zip related improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Oct 8, 2024
1 parent 0a71d3b commit ca6d2a7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Components/Lzma2/Util/7z/7zMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* Changes by Martijn Laan for Inno Setup:
-Use CP_UTF8 in PrintString
-Change main to mainW to support Unicode archive names
-Add specific error text for SZ_ERROR_NO_ARCHIVE
-Add specific error text for SZ_ERROR_ARCHIVE and SZ_ERROR_NO_ARCHIVE
-Return res on errors instead of always returning 1
Otherwise unchanged */

Expand Down Expand Up @@ -879,6 +879,8 @@ int Z7_CDECL mainW(int numargs, WCHAR *args[])
PrintError("cannot allocate memory");
else if (res == SZ_ERROR_CRC)
PrintError("CRC error");
else if (res == SZ_ERROR_ARCHIVE)
PrintError("archive corrupt");
else if (res == SZ_ERROR_NO_ARCHIVE)
PrintError("not an archive");
else if (res == SZ_ERROR_READ /* || archiveStream.Res != 0 */)
Expand Down
7 changes: 5 additions & 2 deletions Projects/Src/Compression.SevenZipDecoder.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ function __CreateFileA(lpFileName: LPCSTR; dwDesiredAccess, dwShareMode: DWORD;
lpSecurityAttributes: PSecurityAttributes; dwCreationDisposition, dwFlagsAndAttributes: DWORD;
hTemplateFile: THandle): THandle; cdecl;
begin
Result := CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
{ Return an error if we do ever get called which is unwanted because it should
use CreateFileW and not CreateFileA }
Result := INVALID_HANDLE_VALUE;
SetLastError(ERROR_INVALID_FUNCTION);
end;

function __CreateFileW(lpFileName: LPCWSTR; dwDesiredAccess, dwShareMode: DWORD;
Expand Down Expand Up @@ -140,7 +143,7 @@ function _memset(dest: Pointer; c: Integer; n: Cardinal): Pointer; cdecl;

function _malloc(size: NativeUInt): Pointer; cdecl;
begin
if size > High(NativeInt) then
if size > NativeUInt(High(NativeInt)) then
Result := nil
else begin
try
Expand Down
Binary file modified Projects/Src/Compression.SevenZipDecoder/7zDecode/IS7zDec.obj
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,6 @@ workflow will be triggered automatically.
[Projects\Src\Compil32]: <Projects/Src/Compil32>
[Projects\Src\Compression.LZMADecompressor\Lzma2Decode]: <Projects/Src/Compression.LZMADecompressor/Lzma2Decode>
[Projects\Src\Compression.LZMA1SmallDecompressor\LzmaDecode]: <Projects/Src/Compression.LZMA1SmallDecompressor/LzmaDecode>
[Projects\Src\Compression.SevenZipDecoder\7zDecode]: <Projects/Src/Compression.SevenZipDecoder/7zDecode>
[7-Zip]: https://www.7-zip.org/
[secret]: https://docs.github.com/en/actions/security-guides/encrypted-secrets
2 changes: 1 addition & 1 deletion whatsnew.htm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</ul>
<p><span class="head2">Other changes</span></p>
<ul>
<li>Updated the LZMA SDK used by Inno Setup to the latest version, increasing the speed of LZMA and LZMA2 compression (by 10% in a test with default settings) without changing the compression ratio. Compression memory requirements have increased by about 4%.</li>
<li>Updated the LZMA SDK used by Inno Setup to the latest version, increasing the speed of LZMA and LZMA2 compression (by 10% in a test with default settings) without changing the compression ratio. Compression memory requirements have increased by about 4%. This also made it possible to add support for extracting 7-Zip archives, see below.</li>
<li>Updated the key derivation function and encryption algorithm used by Inno Setup to PBKDF2-HMAC-SHA256 and XChaCha20 respectively, increasing security. This code is built-in: the separate ISCrypt.dll "encryption module" is no longer used and will be automatically deleted when you update.</li>
<li>Added <tt>[Setup]</tt> section directive <tt>EncryptionKeyDerivation</tt> to change the number of PBKDF2-HMAC-SHA256 iterations to use from the default of 200000 to another value.</li>
<li>Replaced all remaining use of MD5 and SHA-1 hashes with SHA-256 hashes, without removing the MD5 and SHA-1 Pascal Scripting and ISPP support functions.</li>
Expand Down

0 comments on commit ca6d2a7

Please sign in to comment.