mirror of
https://github.com/pbatard/rufus.git
synced 2026-07-09 06:55:39 +00:00
Compare commits
No commits in common. "master" and "v4.15_BETA" have entirely different histories.
master
...
v4.15_BETA
36 changed files with 112 additions and 1004 deletions
2
.github/workflows/codeql.yml
vendored
2
.github/workflows/codeql.yml
vendored
|
|
@ -41,7 +41,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v4
|
uses: github/codeql-action/init@v4
|
||||||
|
|
|
||||||
2
.github/workflows/coverity.yml
vendored
2
.github/workflows/coverity.yml
vendored
|
|
@ -28,7 +28,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
|
||||||
2
.github/workflows/mingw.yml
vendored
2
.github/workflows/mingw.yml
vendored
|
|
@ -54,7 +54,7 @@ jobs:
|
||||||
upx
|
upx
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
|
||||||
2
.github/workflows/setup.yml
vendored
2
.github/workflows/setup.yml
vendored
|
|
@ -19,7 +19,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Add MSBuild to PATH
|
- name: Add MSBuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v3
|
uses: microsoft/setup-msbuild@v3
|
||||||
|
|
|
||||||
2
.github/workflows/vs2026.yml
vendored
2
.github/workflows/vs2026.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\src\bled\bled.c" />
|
<ClCompile Include="..\src\bled\bled.c" />
|
||||||
<ClCompile Include="..\src\bled\bled_size.c" />
|
|
||||||
<ClCompile Include="..\src\bled\crc32.c" />
|
<ClCompile Include="..\src\bled\crc32.c" />
|
||||||
<ClCompile Include="..\src\bled\data_align.c" />
|
<ClCompile Include="..\src\bled\data_align.c" />
|
||||||
<ClCompile Include="..\src\bled\data_extract_all.c" />
|
<ClCompile Include="..\src\bled\data_extract_all.c" />
|
||||||
|
|
@ -162,7 +161,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
|
@ -181,7 +180,7 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
|
@ -200,7 +199,7 @@
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
|
@ -217,7 +216,7 @@
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
|
@ -238,7 +237,7 @@
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
|
@ -257,7 +256,7 @@
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PreprocessorDefinitions>BLED_EXPECT_DISK_IMAGE;_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_OFF_T_DEFINED;_off_t=__int64;off_t=_off_t;_FILE_OFFSET_BITS=64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\src</AdditionalIncludeDirectories>
|
||||||
<CompileAs>CompileAsC</CompileAs>
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,6 @@
|
||||||
<ClCompile Include="..\src\bled\zstd_ddict.c">
|
<ClCompile Include="..\src\bled\zstd_ddict.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\src\bled\bled_size.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\src\bled\bb_archive.h">
|
<ClInclude Include="..\src\bled\bb_archive.h">
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,10 @@
|
||||||
o Version 4.15 (2026.06.30)
|
o Version 4.15 (2026.06.??)
|
||||||
Add RISC-V 64 support to UEFI:NTFS
|
Improve the guards for using the "silent" option
|
||||||
Improve the guards for using the "silent" Windows installation option
|
|
||||||
Improve the ability to cancel during write retries
|
Improve the ability to cancel during write retries
|
||||||
Improve progress reporting for compressed image extraction
|
|
||||||
Fix unrestricted XML entity expansion and integer overflow in ezxml parser (courtesy of Eric Sadowski)
|
Fix unrestricted XML entity expansion and integer overflow in ezxml parser (courtesy of Eric Sadowski)
|
||||||
Fix "silent" Windows installation failing at 75% in most cases
|
Fix "silent" Windows installation failing at 75% in most cases
|
||||||
Fix a crash during boot when using UEFI:NTFS on Snapdragon X based ARM64 platforms
|
Fix a crash during boot when using UEFI:NTFS on Snapdragon X based ARM64 platforms
|
||||||
Fix first WUE option always being checked by default
|
Fix the first WUE option always being checked by default
|
||||||
Fix an infinite loop when using Windows ISOs that contain multiple WIMs
|
Fix an infinite loop when using Windows ISOs that contain multiple WIMs
|
||||||
Fix "Enable runtime UEFI media validation" checkbox not always being properly enabled
|
Fix "Enable runtime UEFI media validation" checkbox not always being properly enabled
|
||||||
Other WUE improvements/fixes for OneDrive removal and username validation (with thanks to @christian8641)
|
Other WUE improvements/fixes for OneDrive removal and username validation (with thanks to @christian8641)
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
• Pakeitimų žurnalas: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus adalah utiliti yang membantu memformat dan mencipta pemacu kilat USB boot, seperti pemacu pen/kekunci USB, kayu memori, dan lain-lain.
|
• Pakeitimų žurnalas: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus adalah utiliti yang membantu memformat dan mencipta pemacu kilat USB boot, seperti pemacu pen/kekunci USB, kayu memori, dan lain-lain.
|
||||||
• Laman rasmi: https://rufus.ie
|
• Laman rasmi: https://rufus.ie
|
||||||
• Kod Sumber: https://github.com/pbatard/rufus
|
• Kod Sumber: https://github.com/pbatard/rufus
|
||||||
• Log Perubahan: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus er et verktøy som hjelper til med å formatere og lage oppstartbare USB-stasjoner, for eksempel USB-minnepinner, USB-harddisker, og lignende.
|
• ChangeLog: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus er et verktøy som hjelper til med å formatere og lage oppstartbare USB-stasjoner, for eksempel USB-minnepinner, USB-harddisker, og lignende.
|
||||||
• Offisiell webside: https://rufus.ie
|
• Offisiell webside: https://rufus.ie
|
||||||
• Kildekode: https://github.com/pbatard/rufus
|
• Kildekode: https://github.com/pbatard/rufus
|
||||||
• Endringslogg: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus ابزاری است که به فرمت و ایجاد درایوهای فلش USB قابل بوت، مانند کلیدهای USB/pendrives، مموری استیک ها و غیره به شما کمک می کند.
|
• Endringslogg: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt","Rufus ابزاری است که به فرمت و ایجاد درایوهای فلش USB قابل بوت، مانند کلیدهای USB/pendrives، مموری استیک ها و غیره به شما کمک می کند.
|
||||||
|
|
@ -114,17 +114,19 @@
|
||||||
• Trang web chính thức: https://rufus.ie
|
• Trang web chính thức: https://rufus.ie
|
||||||
• Mã nguồn: https://github.com/pbatard/rufus
|
• Mã nguồn: https://github.com/pbatard/rufus
|
||||||
• Nhật ký thay đổi: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt"
|
• Nhật ký thay đổi: https://github.com/pbatard/rufus/blob/master/ChangeLog.txt"
|
||||||
"ReleaseNotes","3","Text","• Add RISC-V 64 support to UEFI:NTFS
|
"ReleaseNotes","3","Text","• Windows User Experience improvements:
|
||||||
• Improve the guards for using the ""silent"" Windows installation option
|
• - Add a ""Quality of Life"" option, to disable Teams, Outlook, Copilot and other Microsoft forced nuisances
|
||||||
• Improve the ability to cancel during write retries
|
• - Add a Silent installation option, that automatically, and WITHOUT PROMPT, installs Windows on the first detected disk
|
||||||
• Improve progress reporting for compressed image extraction
|
• - Add an option to copy 'SkuSiPolicy.p7b' to the ESP on installation (please refer to KB5042562 for more info)
|
||||||
• Fix unrestricted XML entity expansion and integer overflow in ezxml parser (courtesy of Eric Sadowski)
|
• - Add tooltips for all the dialog options
|
||||||
• Fix ""silent"" Windows installation failing at 75% in most cases
|
• Add limited support for El-Torito UEFI image extraction (Mostly for Dell BIOS update ISOs)
|
||||||
• Fix a crash during boot when using UEFI:NTFS on Snapdragon X based ARM64 platforms
|
• Improve error report when the user tries to use an image that resides on the target drive
|
||||||
• Fix first WUE option always being checked by default
|
• Improve the UEFI:NTFS partition label to make the install media more explicit during Windows Setup disk partitioning
|
||||||
• Fix an infinite loop when using Windows ISOs that contain multiple WIMs
|
• Improve support for Bazzite and other Fedora derivatives that don't follow EFI conventions
|
||||||
• Fix ""Enable runtime UEFI media validation"" checkbox not always being properly enabled
|
• Improve detection and exclusion of the new Bitdefender hidden VHDs
|
||||||
• Other WUE improvements/fixes for OneDrive removal and username validation (with thanks to @christian8641)",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
• Improve reporting of GRUB and Isolinux MBRs
|
||||||
|
• Fix potential errors during creation of Windows To Go media, due to the use of new versions of bcdboot
|
||||||
|
• Fix errors with local accounts that start or end with whitespaces",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
"Title","4","Text","Rufus",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
"Title","4","Text","Rufus",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
"ShortTitle","5","Text","",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
"ShortTitle","5","Text","",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
"SortTitle","6","Text","",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
"SortTitle","6","Text","",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
|
||||||
|
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ This image, which can be mounted as a FAT file system or opened in 7-zip,
|
||||||
contains the following data:
|
contains the following data:
|
||||||
|
|
||||||
o Secure Boot signed NTFS UEFI drivers, derived from ntfs-3g [1].
|
o Secure Boot signed NTFS UEFI drivers, derived from ntfs-3g [1].
|
||||||
These drivers are the exact same as the read-only binaries from release 1.9,
|
These drivers are the exact same as the read-only binaries from release 1.8,
|
||||||
except for the addition of Microsoft's Secure Boot signature.
|
except for the addition of Microsoft's Secure Boot signature.
|
||||||
|
|
||||||
o Non Secure Boot signed exFAT (and ARM/RISC NTFS) UEFI drivers from EfiFs [2].
|
o Non Secure Boot signed exFAT (and ARM NTFS) UEFI drivers from EfiFs [2].
|
||||||
These drivers are the exact same as the binaries from EfiFs release 1.12 but,
|
These drivers are the exact same as the binaries from EfiFs release 1.12 but,
|
||||||
because they are licensed under GPLv3, cannot be Secure Boot signed.
|
because they are licensed under GPLv3, cannot be Secure Boot signed.
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,10 +1,10 @@
|
||||||
noinst_LIBRARIES = libbled.a
|
noinst_LIBRARIES = libbled.a
|
||||||
|
|
||||||
libbled_a_SOURCES = bled.c bled_size.c crc32.c data_align.c data_extract_all.c data_skip.c decompress_bunzip2.c \
|
libbled_a_SOURCES = bled.c crc32.c data_align.c data_extract_all.c data_skip.c decompress_bunzip2.c \
|
||||||
decompress_gunzip.c decompress_uncompress.c decompress_unlzma.c decompress_unxz.c decompress_unzip.c \
|
decompress_gunzip.c decompress_uncompress.c decompress_unlzma.c decompress_unxz.c decompress_unzip.c \
|
||||||
decompress_unzstd.c decompress_vtsi.c filter_accept_all.c filter_accept_list.c filter_accept_reject_list.c \
|
decompress_unzstd.c decompress_vtsi.c filter_accept_all.c filter_accept_list.c filter_accept_reject_list.c \
|
||||||
find_list_entry.c fse_decompress.c header_list.c header_skip.c header_verbose_list.c huf_decompress.c \
|
find_list_entry.c fse_decompress.c header_list.c header_skip.c header_verbose_list.c huf_decompress.c \
|
||||||
init_handle.c open_transformer.c seek_by_jump.c seek_by_read.c xz_dec_bcj.c xz_dec_lzma2.c xz_dec_stream.c \
|
init_handle.c open_transformer.c seek_by_jump.c seek_by_read.c xz_dec_bcj.c xz_dec_lzma2.c xz_dec_stream.c \
|
||||||
xxhash.c zstd_common.c zstd_decompress.c zstd_decompress_block.c zstd_ddict.c zstd_entropy_common.c \
|
xxhash.c zstd_common.c zstd_decompress.c zstd_decompress_block.c zstd_ddict.c zstd_entropy_common.c \
|
||||||
zstd_error_private.c
|
zstd_error_private.c
|
||||||
libbled_a_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/.. -DBLED_EXPECT_DISK_IMAGE -Wno-undef -Wno-strict-aliasing
|
libbled_a_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/.. -Wno-undef -Wno-strict-aliasing
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,7 @@ am__v_AR_1 =
|
||||||
libbled_a_AR = $(AR) $(ARFLAGS)
|
libbled_a_AR = $(AR) $(ARFLAGS)
|
||||||
libbled_a_LIBADD =
|
libbled_a_LIBADD =
|
||||||
am_libbled_a_OBJECTS = libbled_a-bled.$(OBJEXT) \
|
am_libbled_a_OBJECTS = libbled_a-bled.$(OBJEXT) \
|
||||||
libbled_a-bled_size.$(OBJEXT) libbled_a-crc32.$(OBJEXT) \
|
libbled_a-crc32.$(OBJEXT) libbled_a-data_align.$(OBJEXT) \
|
||||||
libbled_a-data_align.$(OBJEXT) \
|
|
||||||
libbled_a-data_extract_all.$(OBJEXT) \
|
libbled_a-data_extract_all.$(OBJEXT) \
|
||||||
libbled_a-data_skip.$(OBJEXT) \
|
libbled_a-data_skip.$(OBJEXT) \
|
||||||
libbled_a-decompress_bunzip2.$(OBJEXT) \
|
libbled_a-decompress_bunzip2.$(OBJEXT) \
|
||||||
|
|
@ -277,7 +276,7 @@ top_build_prefix = @top_build_prefix@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
noinst_LIBRARIES = libbled.a
|
noinst_LIBRARIES = libbled.a
|
||||||
libbled_a_SOURCES = bled.c bled_size.c crc32.c data_align.c data_extract_all.c data_skip.c decompress_bunzip2.c \
|
libbled_a_SOURCES = bled.c crc32.c data_align.c data_extract_all.c data_skip.c decompress_bunzip2.c \
|
||||||
decompress_gunzip.c decompress_uncompress.c decompress_unlzma.c decompress_unxz.c decompress_unzip.c \
|
decompress_gunzip.c decompress_uncompress.c decompress_unlzma.c decompress_unxz.c decompress_unzip.c \
|
||||||
decompress_unzstd.c decompress_vtsi.c filter_accept_all.c filter_accept_list.c filter_accept_reject_list.c \
|
decompress_unzstd.c decompress_vtsi.c filter_accept_all.c filter_accept_list.c filter_accept_reject_list.c \
|
||||||
find_list_entry.c fse_decompress.c header_list.c header_skip.c header_verbose_list.c huf_decompress.c \
|
find_list_entry.c fse_decompress.c header_list.c header_skip.c header_verbose_list.c huf_decompress.c \
|
||||||
|
|
@ -285,7 +284,7 @@ libbled_a_SOURCES = bled.c bled_size.c crc32.c data_align.c data_extract_all.c d
|
||||||
xxhash.c zstd_common.c zstd_decompress.c zstd_decompress_block.c zstd_ddict.c zstd_entropy_common.c \
|
xxhash.c zstd_common.c zstd_decompress.c zstd_decompress_block.c zstd_ddict.c zstd_entropy_common.c \
|
||||||
zstd_error_private.c
|
zstd_error_private.c
|
||||||
|
|
||||||
libbled_a_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/.. -DBLED_EXPECT_DISK_IMAGE -Wno-undef -Wno-strict-aliasing
|
libbled_a_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/.. -Wno-undef -Wno-strict-aliasing
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
@ -347,12 +346,6 @@ libbled_a-bled.o: bled.c
|
||||||
libbled_a-bled.obj: bled.c
|
libbled_a-bled.obj: bled.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-bled.obj `if test -f 'bled.c'; then $(CYGPATH_W) 'bled.c'; else $(CYGPATH_W) '$(srcdir)/bled.c'; fi`
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-bled.obj `if test -f 'bled.c'; then $(CYGPATH_W) 'bled.c'; else $(CYGPATH_W) '$(srcdir)/bled.c'; fi`
|
||||||
|
|
||||||
libbled_a-bled_size.o: bled_size.c
|
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-bled_size.o `test -f 'bled_size.c' || echo '$(srcdir)/'`bled_size.c
|
|
||||||
|
|
||||||
libbled_a-bled_size.obj: bled_size.c
|
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-bled_size.obj `if test -f 'bled_size.c'; then $(CYGPATH_W) 'bled_size.c'; else $(CYGPATH_W) '$(srcdir)/bled_size.c'; fi`
|
|
||||||
|
|
||||||
libbled_a-crc32.o: crc32.c
|
libbled_a-crc32.o: crc32.c
|
||||||
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-crc32.o `test -f 'crc32.c' || echo '$(srcdir)/'`crc32.c
|
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libbled_a_CFLAGS) $(CFLAGS) -c -o libbled_a-crc32.o `test -f 'crc32.c' || echo '$(srcdir)/'`crc32.c
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,13 +235,11 @@ typedef struct transformer_state_t {
|
||||||
int dst_fd;
|
int dst_fd;
|
||||||
const char *dst_dir; /* if non-NULL, extract to dir */
|
const char *dst_dir; /* if non-NULL, extract to dir */
|
||||||
char *dst_name;
|
char *dst_name;
|
||||||
int64_t src_size; /* size of the source archive */
|
uint64_t dst_size;
|
||||||
int64_t dst_size; /* size of the uncompressed data, if available */
|
|
||||||
size_t mem_output_size_max; /* if non-zero, decompress to RAM instead of fd */
|
size_t mem_output_size_max; /* if non-zero, decompress to RAM instead of fd */
|
||||||
size_t mem_output_size;
|
size_t mem_output_size;
|
||||||
char *mem_output_buf;
|
char *mem_output_buf;
|
||||||
|
|
||||||
uint64_t bytes_total; /* used in unzip code only, for directory extraction */
|
|
||||||
uint64_t bytes_out;
|
uint64_t bytes_out;
|
||||||
uint64_t bytes_in; /* used in unzip code only: needs to know packed size */
|
uint64_t bytes_in; /* used in unzip code only: needs to know packed size */
|
||||||
uint32_t crc32;
|
uint32_t crc32;
|
||||||
|
|
@ -254,9 +252,6 @@ typedef struct transformer_state_t {
|
||||||
} magic;
|
} magic;
|
||||||
} transformer_state_t;
|
} transformer_state_t;
|
||||||
|
|
||||||
typedef int64_t(*unpacker_t)(transformer_state_t* xstate);
|
|
||||||
typedef int64_t(*get_uncompressed_size_t)(int fd);
|
|
||||||
int64_t get_uncompressed_size(int fd, int type);
|
|
||||||
void init_transformer_state(transformer_state_t *xstate) FAST_FUNC;
|
void init_transformer_state(transformer_state_t *xstate) FAST_FUNC;
|
||||||
ssize_t transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
|
ssize_t transformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
|
||||||
ssize_t xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
|
ssize_t xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize) FAST_FUNC;
|
||||||
|
|
@ -281,7 +276,7 @@ static inline int transformer_switch_file(transformer_state_t* xstate)
|
||||||
last_slash = i;
|
last_slash = i;
|
||||||
}
|
}
|
||||||
if (bled_switch != NULL)
|
if (bled_switch != NULL)
|
||||||
bled_switch(dst, xstate->bytes_total);
|
bled_switch(dst, xstate->dst_size);
|
||||||
dst[last_slash] = 0;
|
dst[last_slash] = 0;
|
||||||
bb_make_directory(dst, 0, 0);
|
bb_make_directory(dst, 0, 0);
|
||||||
dst[last_slash] = '/';
|
dst[last_slash] = '/';
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Bled (Base Library for Easy Decompression)
|
* Bled (Base Library for Easy Decompression)
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2026 Pete Batard <pete@akeo.ie>
|
* Copyright © 2014-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
@ -15,26 +15,27 @@
|
||||||
#include "bb_archive.h"
|
#include "bb_archive.h"
|
||||||
#include "bled.h"
|
#include "bled.h"
|
||||||
|
|
||||||
|
typedef long long int(*unpacker_t)(transformer_state_t *xstate);
|
||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
smallint bb_got_signal;
|
smallint bb_got_signal;
|
||||||
uint64_t bb_total_rb, bb_total_wb;
|
uint64_t bb_total_rb;
|
||||||
printf_t bled_printf = NULL;
|
printf_t bled_printf = NULL;
|
||||||
read_t bled_read = NULL;
|
read_t bled_read = NULL;
|
||||||
write_t bled_write = NULL;
|
write_t bled_write = NULL;
|
||||||
progress_t bled_progress = NULL;
|
progress_t bled_progress = NULL;
|
||||||
switch_t bled_switch = NULL;
|
switch_t bled_switch = NULL;
|
||||||
unsigned long* bled_cancel_request;
|
unsigned long* bled_cancel_request;
|
||||||
bool bled_initialized = 0;
|
static bool bled_initialized = 0;
|
||||||
jmp_buf bb_error_jmp;
|
jmp_buf bb_error_jmp;
|
||||||
char* bb_virtual_buf = NULL;
|
char* bb_virtual_buf = NULL;
|
||||||
size_t bb_virtual_len = 0, bb_virtual_pos = 0;
|
size_t bb_virtual_len = 0, bb_virtual_pos = 0;
|
||||||
int bb_virtual_fd = -1;
|
int bb_virtual_fd = -1;
|
||||||
bool bb_progress_on_write = 0;
|
|
||||||
// ZSTD has a minimal buffer size of (1 << ZSTD_BLOCKSIZELOG_MAX) + ZSTD_blockHeaderSize = 128 KB + 3
|
// ZSTD has a minimal buffer size of (1 << ZSTD_BLOCKSIZELOG_MAX) + ZSTD_blockHeaderSize = 128 KB + 3
|
||||||
// So we set our bufsize to 256 KB
|
// So we set our bufsize to 256 KB
|
||||||
uint32_t BB_BUFSIZE = 0x40000;
|
uint32_t BB_BUFSIZE = 0x40000;
|
||||||
|
|
||||||
static int64_t unpack_none(transformer_state_t *xstate)
|
static long long int unpack_none(transformer_state_t *xstate)
|
||||||
{
|
{
|
||||||
bb_error_msg("This compression type is not supported");
|
bb_error_msg("This compression type is not supported");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -65,7 +66,6 @@ int64_t bled_uncompress(const char* src, const char* dst, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_total_rb = 0;
|
bb_total_rb = 0;
|
||||||
bb_total_wb = 0;
|
|
||||||
init_transformer_state(&xstate);
|
init_transformer_state(&xstate);
|
||||||
xstate.src_fd = -1;
|
xstate.src_fd = -1;
|
||||||
xstate.dst_fd = -1;
|
xstate.dst_fd = -1;
|
||||||
|
|
@ -87,14 +87,6 @@ int64_t bled_uncompress(const char* src, const char* dst, int type)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bled_progress != NULL) {
|
|
||||||
xstate.src_size = lseek(xstate.src_fd, 0, SEEK_END);
|
|
||||||
xstate.dst_size = get_uncompressed_size(xstate.src_fd, type);
|
|
||||||
|
|
||||||
bb_progress_on_write = (xstate.dst_size > 0);
|
|
||||||
bled_progress(bb_progress_on_write ? -xstate.dst_size : -xstate.src_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setjmp(bb_error_jmp))
|
if (setjmp(bb_error_jmp))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
@ -120,7 +112,6 @@ int64_t bled_uncompress_with_handles(HANDLE hSrc, HANDLE hDst, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_total_rb = 0;
|
bb_total_rb = 0;
|
||||||
bb_total_wb = 0;
|
|
||||||
init_transformer_state(&xstate);
|
init_transformer_state(&xstate);
|
||||||
xstate.src_fd = -1;
|
xstate.src_fd = -1;
|
||||||
xstate.dst_fd = -1;
|
xstate.dst_fd = -1;
|
||||||
|
|
@ -142,13 +133,6 @@ int64_t bled_uncompress_with_handles(HANDLE hSrc, HANDLE hDst, int type)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bled_progress != NULL) {
|
|
||||||
xstate.src_size = lseek(xstate.src_fd, 0, SEEK_END);
|
|
||||||
xstate.dst_size = get_uncompressed_size(xstate.src_fd, type);
|
|
||||||
bb_progress_on_write = (xstate.dst_size > 0);
|
|
||||||
bled_progress(bb_progress_on_write ? -xstate.dst_size : -xstate.src_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setjmp(bb_error_jmp))
|
if (setjmp(bb_error_jmp))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
@ -172,7 +156,6 @@ int64_t bled_uncompress_to_buffer(const char* src, char* buf, size_t size, int t
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_total_rb = 0;
|
bb_total_rb = 0;
|
||||||
bb_total_wb = 0;
|
|
||||||
init_transformer_state(&xstate);
|
init_transformer_state(&xstate);
|
||||||
xstate.src_fd = -1;
|
xstate.src_fd = -1;
|
||||||
xstate.dst_fd = -1;
|
xstate.dst_fd = -1;
|
||||||
|
|
@ -196,13 +179,6 @@ int64_t bled_uncompress_to_buffer(const char* src, char* buf, size_t size, int t
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bled_progress != NULL) {
|
|
||||||
xstate.src_size = lseek(xstate.src_fd, 0, SEEK_END);
|
|
||||||
xstate.dst_size = get_uncompressed_size(xstate.src_fd, type);
|
|
||||||
bb_progress_on_write = (xstate.dst_size > 0);
|
|
||||||
bled_progress(bb_progress_on_write ? -xstate.dst_size : -xstate.src_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setjmp(bb_error_jmp))
|
if (setjmp(bb_error_jmp))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
@ -227,7 +203,6 @@ int64_t bled_uncompress_to_dir(const char* src, const char* dir, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_total_rb = 0;
|
bb_total_rb = 0;
|
||||||
bb_total_wb = 0;
|
|
||||||
init_transformer_state(&xstate);
|
init_transformer_state(&xstate);
|
||||||
xstate.src_fd = -1;
|
xstate.src_fd = -1;
|
||||||
xstate.dst_fd = -1;
|
xstate.dst_fd = -1;
|
||||||
|
|
@ -246,13 +221,6 @@ int64_t bled_uncompress_to_dir(const char* src, const char* dir, int type)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bled_progress != NULL) {
|
|
||||||
xstate.src_size = lseek(xstate.src_fd, 0, SEEK_END);
|
|
||||||
xstate.dst_size = 0;
|
|
||||||
bb_progress_on_write = 0;
|
|
||||||
bled_progress(-xstate.src_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setjmp(bb_error_jmp))
|
if (setjmp(bb_error_jmp))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
@ -300,34 +268,6 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the decompressed size of file 'src', compressed using 'type' */
|
|
||||||
int64_t bled_get_uncompressed_size(const char* src, int type)
|
|
||||||
{
|
|
||||||
int fd = -1;
|
|
||||||
int64_t ret = -1;
|
|
||||||
|
|
||||||
if (!bled_initialized) {
|
|
||||||
bb_error_msg("The library has not been initialized");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) {
|
|
||||||
bb_error_msg("Unsupported compression format");
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = _openU(src, _O_RDONLY | _O_BINARY, 0);
|
|
||||||
if (fd < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ret = get_uncompressed_size(fd, type);
|
|
||||||
|
|
||||||
err:
|
|
||||||
if (fd > 0)
|
|
||||||
_close(fd);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize the library.
|
/* Initialize the library.
|
||||||
* When the parameters are not NULL or zero you can:
|
* When the parameters are not NULL or zero you can:
|
||||||
* - specify the buffer size to use (must be larger than 256KB and a power of two)
|
* - specify the buffer size to use (must be larger than 256KB and a power of two)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Bled (Base Library for Easy Decompression)
|
* Bled (Base Library for Easy Decompression)
|
||||||
*
|
*
|
||||||
* Copyright © 2014-2026 Pete Batard <pete@akeo.ie>
|
* Copyright © 2014-2024 Pete Batard <pete@akeo.ie>
|
||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||||
*/
|
*/
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void (*printf_t) (const char* format, ...);
|
typedef void (*printf_t) (const char* format, ...);
|
||||||
typedef void (*progress_t) (const int64_t read_bytes);
|
typedef void (*progress_t) (const uint64_t read_bytes);
|
||||||
typedef int (*read_t)(int fd, void* buf, unsigned int count);
|
typedef int (*read_t)(int fd, void* buf, unsigned int count);
|
||||||
typedef int (*write_t)(int fd, const void* buf, unsigned int count);
|
typedef int (*write_t)(int fd, const void* buf, unsigned int count);
|
||||||
typedef void (*switch_t)(const char* filename, const uint64_t size);
|
typedef void (*switch_t)(const char* filename, const uint64_t size);
|
||||||
|
|
@ -35,9 +35,6 @@ typedef enum {
|
||||||
BLED_COMPRESSION_MAX
|
BLED_COMPRESSION_MAX
|
||||||
} bled_compression_type;
|
} bled_compression_type;
|
||||||
|
|
||||||
/* (Where possible) get the uncompressed size of file 'src', compressed using 'type' */
|
|
||||||
int64_t bled_get_uncompressed_size(const char* src, int type);
|
|
||||||
|
|
||||||
/* Uncompress file 'src', compressed using 'type', to file 'dst' */
|
/* Uncompress file 'src', compressed using 'type', to file 'dst' */
|
||||||
int64_t bled_uncompress(const char* src, const char* dst, int type);
|
int64_t bled_uncompress(const char* src, const char* dst, int type);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,782 +0,0 @@
|
||||||
/*
|
|
||||||
* Bled (Base Library for Easy Decompression) - Size related dependencies
|
|
||||||
*
|
|
||||||
* Mostly generated by AI - No copyright assigned.
|
|
||||||
*
|
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _CRTDBG_MAP_ALLOC
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libbb.h"
|
|
||||||
#include "bb_archive.h"
|
|
||||||
#include "bled.h"
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* Internal helpers
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define DECOMP_SIZE_ERROR ((int64_t)-1)
|
|
||||||
#define DECOMP_SIZE_UNKNOWN ((int64_t)-2)
|
|
||||||
#define DECOMP_IO_ERROR ((int64_t)-3)
|
|
||||||
|
|
||||||
/** Read exactly n bytes from fd into buf; returns 0 on success, -1 on error. */
|
|
||||||
static int read_exact(int fd, void* buf, size_t n)
|
|
||||||
{
|
|
||||||
uint8_t* p = (uint8_t*)buf;
|
|
||||||
while (n > 0) {
|
|
||||||
int got = _read(fd, p, (unsigned)n);
|
|
||||||
if (got <= 0)
|
|
||||||
return -1;
|
|
||||||
p += got;
|
|
||||||
n -= (size_t)got;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t get_uncompress_size_none(int fd)
|
|
||||||
{
|
|
||||||
return DECOMP_SIZE_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* PKZIP
|
|
||||||
*
|
|
||||||
* Local File Header layout (all fields little-endian):
|
|
||||||
*
|
|
||||||
* Offset Size Field
|
|
||||||
* 0 4 Signature (0x04034b50)
|
|
||||||
* 4 2 Version needed
|
|
||||||
* 6 2 General purpose bit flag
|
|
||||||
* 8 2 Compression method
|
|
||||||
* 10 2 Last mod file time
|
|
||||||
* 12 2 Last mod file date
|
|
||||||
* 14 4 CRC-32
|
|
||||||
* 18 4 Compressed size (0xFFFFFFFF → see ZIP64 Extra Field)
|
|
||||||
* 22 4 Uncompressed size (0xFFFFFFFF → see ZIP64 Extra Field)
|
|
||||||
* 26 2 File name length
|
|
||||||
* 28 2 Extra field length
|
|
||||||
* 30 ? File name
|
|
||||||
* 30+n ? Extra field
|
|
||||||
*
|
|
||||||
* ZIP64 Extra Field tag: 0x0001
|
|
||||||
* Within the ZIP64 extra field block the fields appear only when the
|
|
||||||
* corresponding 32-bit field in the Local Header is 0xFFFFFFFF:
|
|
||||||
* - Original size (8 bytes LE) ← first, if uncompressed == 0xFFFFFFFF
|
|
||||||
* - Compressed size (8 bytes LE) ← second, if compressed == 0xFFFFFFFF
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define ZIP_LFH_SIG UINT32_C(0x04034b50)
|
|
||||||
#define ZIP_LFH_HDR_SIZE 30
|
|
||||||
#define ZIP64_EXTRA_TAG 0x0001
|
|
||||||
#define ZIP32_NEEDS_ZIP64 UINT32_C(0xFFFFFFFF)
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_zip(int fd)
|
|
||||||
{
|
|
||||||
uint8_t hdr[ZIP_LFH_HDR_SIZE];
|
|
||||||
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, hdr, ZIP_LFH_HDR_SIZE))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Verify Local File Header signature. */
|
|
||||||
if (get_le32(hdr + 0) != ZIP_LFH_SIG)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint32_t uncomp32 = get_le32(hdr + 22);
|
|
||||||
uint32_t comp32 = get_le32(hdr + 18);
|
|
||||||
uint16_t fname_len = get_le16(hdr + 26);
|
|
||||||
uint16_t extra_len = get_le16(hdr + 28);
|
|
||||||
|
|
||||||
/* Fast path: 32-bit field is valid. */
|
|
||||||
if (uncomp32 != ZIP32_NEEDS_ZIP64)
|
|
||||||
return (int64_t)uncomp32;
|
|
||||||
|
|
||||||
/* Need ZIP64 Extra Field – skip over the file name first. */
|
|
||||||
if (lseek(fd, (int64_t)fname_len, SEEK_CUR) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Walk the extra field TLV blocks looking for tag 0x0001. */
|
|
||||||
uint16_t remaining = extra_len;
|
|
||||||
while (remaining >= 4) {
|
|
||||||
uint8_t tag_buf[4];
|
|
||||||
if (read_exact(fd, tag_buf, 4))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
remaining = (uint16_t)(remaining - 4);
|
|
||||||
|
|
||||||
uint16_t tag = get_le16(tag_buf + 0);
|
|
||||||
uint16_t dlen = get_le16(tag_buf + 2);
|
|
||||||
|
|
||||||
if (tag == ZIP64_EXTRA_TAG) {
|
|
||||||
/*
|
|
||||||
* Fields are present only when the corresponding 32-bit value is
|
|
||||||
* 0xFFFFFFFF. Uncompressed size comes first; we need 8 bytes.
|
|
||||||
*/
|
|
||||||
if (uncomp32 == ZIP32_NEEDS_ZIP64) {
|
|
||||||
if (dlen < 8 || remaining < 8)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
uint8_t sz[8];
|
|
||||||
if (read_exact(fd, sz, 8))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
return (int64_t)get_le64(sz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip this block. */
|
|
||||||
if (dlen > remaining) return DECOMP_SIZE_ERROR;
|
|
||||||
if (lseek(fd, (int64_t)dlen, SEEK_CUR) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
remaining = (uint16_t)(remaining - dlen);
|
|
||||||
(void)comp32; /* suppress unused-variable warning */
|
|
||||||
}
|
|
||||||
|
|
||||||
return DECOMP_SIZE_ERROR; /* ZIP64 tag not found */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* GZIP
|
|
||||||
*
|
|
||||||
* The ISIZE field is the last 4 bytes of the file (little-endian uint32).
|
|
||||||
* It holds the decompressed size modulo 2^32.
|
|
||||||
*
|
|
||||||
* Header magic: 0x1F 0x8B
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define GZIP_MAGIC_0 0x1F
|
|
||||||
#define GZIP_MAGIC_1 0x8B
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_gz(int fd)
|
|
||||||
{
|
|
||||||
/* Verify magic bytes at offset 0. */
|
|
||||||
uint8_t magic[2];
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, magic, 2))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (magic[0] != GZIP_MAGIC_0 || magic[1] != GZIP_MAGIC_1)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Seek to ISIZE: last 4 bytes of the file. */
|
|
||||||
if (lseek(fd, -4, SEEK_END) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t isize[4];
|
|
||||||
if (read_exact(fd, isize, 4))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ISIZE is uint32 mod 2^32. We return it as int64_t; callers that need
|
|
||||||
* to handle files >= 4 GiB must apply their own correction.
|
|
||||||
*/
|
|
||||||
return (int64_t)(uint64_t)get_le32(isize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* LZMA (.lzma "alone" format)
|
|
||||||
*
|
|
||||||
* Header layout:
|
|
||||||
* Offset Size Field
|
|
||||||
* 0 1 Properties byte (lc, lp, pb encoded)
|
|
||||||
* 1 4 Dictionary size (uint32 LE)
|
|
||||||
* 5 8 Uncompressed size (uint64 LE;
|
|
||||||
* 0xFFFFFFFFFFFFFFFF → unknown, uses EOS marker)
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define LZMA_HEADER_SIZE 13 /* 1 + 4 + 8 */
|
|
||||||
#define LZMA_SIZE_UNKNOWN UINT64_C(0xFFFFFFFFFFFFFFFF)
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_lzma(int fd)
|
|
||||||
{
|
|
||||||
uint8_t hdr[LZMA_HEADER_SIZE];
|
|
||||||
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, hdr, LZMA_HEADER_SIZE))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic sanity check on the properties byte:
|
|
||||||
* lc = props % 9, lp = (props / 9) % 5, pb = props / 45
|
|
||||||
* pb must be <= 4, so the byte must be < 225 (9 * 5 * 5).
|
|
||||||
*/
|
|
||||||
if (hdr[0] >= 225)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint64_t size = get_le64(hdr + 5);
|
|
||||||
if (size == LZMA_SIZE_UNKNOWN)
|
|
||||||
return DECOMP_SIZE_UNKNOWN;
|
|
||||||
|
|
||||||
return (int64_t)size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* XZ (.xz)
|
|
||||||
*
|
|
||||||
* An XZ file is one or more Streams, each structured as:
|
|
||||||
*
|
|
||||||
* Stream Header (12 bytes)
|
|
||||||
* Block(s) (variable)
|
|
||||||
* Index (variable)
|
|
||||||
* Stream Footer (12 bytes)
|
|
||||||
*
|
|
||||||
* Stream Footer layout (little-endian unless noted):
|
|
||||||
* Offset Size Field
|
|
||||||
* 0 4 CRC32 of bytes 4..7
|
|
||||||
* 4 4 Backward Size (uint32 LE; index_size = (value+1)*4)
|
|
||||||
* 8 2 Stream Flags (must match Stream Header flags)
|
|
||||||
* 10 2 Magic (0x59 0x5A)
|
|
||||||
*
|
|
||||||
* Index layout (immediately before Stream Footer):
|
|
||||||
* [0] 1 Indicator byte (must be 0x00)
|
|
||||||
* [1] VLI Number of Records
|
|
||||||
* per record:
|
|
||||||
* VLI Unpadded Size of the compressed Block
|
|
||||||
* VLI Uncompressed Size of the Block ← what we want
|
|
||||||
* padding to 4-byte boundary
|
|
||||||
* 4 CRC32 of the Index
|
|
||||||
*
|
|
||||||
* VLI encoding: up to 9 bytes; each byte contributes 7 bits (little-endian
|
|
||||||
* bit order); the MSB is a continuation flag (1 = more bytes follow).
|
|
||||||
* Maximum value: 2^63 - 1 (high bit of the 9th byte must be 0).
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define XZ_STREAM_FOOTER_SIZE 12
|
|
||||||
#define XZ_MAGIC_0 0xFDu
|
|
||||||
#define XZ_MAGIC_1 0x37u
|
|
||||||
#define XZ_MAGIC_2 0x7Au
|
|
||||||
#define XZ_MAGIC_3 0x58u
|
|
||||||
#define XZ_MAGIC_4 0x5Au
|
|
||||||
#define XZ_MAGIC_5 0x00u
|
|
||||||
#define XZ_FOOTER_MAGIC_0 0x59u
|
|
||||||
#define XZ_FOOTER_MAGIC_1 0x5Au
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode one XZ/LZMA2 VLI from buf[*pos], advancing *pos.
|
|
||||||
* Returns the value, or UINT64_MAX on error (overlong / overflow).
|
|
||||||
*/
|
|
||||||
static uint64_t xz_read_vli(const uint8_t* buf, size_t buf_len, size_t* pos)
|
|
||||||
{
|
|
||||||
uint64_t val = 0;
|
|
||||||
int shift = 0;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (*pos >= buf_len) return UINT64_MAX; /* truncated */
|
|
||||||
if (shift >= 63) return UINT64_MAX; /* overlong */
|
|
||||||
|
|
||||||
uint8_t b = buf[(*pos)++];
|
|
||||||
val |= (uint64_t)(b & 0x7Fu) << shift;
|
|
||||||
shift += 7;
|
|
||||||
|
|
||||||
if (!(b & 0x80u))
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_xz(int fd)
|
|
||||||
{
|
|
||||||
/* ---- Verify Stream Header magic (6 bytes at offset 0) ---- */
|
|
||||||
uint8_t hdr_magic[6];
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, hdr_magic, 6))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (hdr_magic[0] != XZ_MAGIC_0 || hdr_magic[1] != XZ_MAGIC_1 ||
|
|
||||||
hdr_magic[2] != XZ_MAGIC_2 || hdr_magic[3] != XZ_MAGIC_3 ||
|
|
||||||
hdr_magic[4] != XZ_MAGIC_4 || hdr_magic[5] != XZ_MAGIC_5)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* ---- Read Stream Footer ---- */
|
|
||||||
if (lseek(fd, -(int64_t)XZ_STREAM_FOOTER_SIZE, SEEK_END) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t footer[XZ_STREAM_FOOTER_SIZE];
|
|
||||||
if (read_exact(fd, footer, XZ_STREAM_FOOTER_SIZE))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Check footer magic bytes at offset 10-11 */
|
|
||||||
if (footer[10] != XZ_FOOTER_MAGIC_0 || footer[11] != XZ_FOOTER_MAGIC_1)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Backward Size: real Index size = (backward_size + 1) * 4 */
|
|
||||||
uint32_t backward_size = get_le32(footer + 4);
|
|
||||||
size_t index_size = ((size_t)backward_size + 1u) * 4u;
|
|
||||||
|
|
||||||
/* ---- Read Index block ---- */
|
|
||||||
int64_t index_offset =
|
|
||||||
-(int64_t)XZ_STREAM_FOOTER_SIZE - (int64_t)index_size;
|
|
||||||
if (lseek(fd, index_offset, SEEK_END) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t* index_buf = (uint8_t*)
|
|
||||||
_alloca(index_size);
|
|
||||||
if (read_exact(fd, index_buf, index_size))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* ---- Parse Index ---- */
|
|
||||||
size_t pos = 0;
|
|
||||||
|
|
||||||
/* Indicator byte must be 0x00 */
|
|
||||||
if (index_buf[pos++] != 0x00u)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Number of Records */
|
|
||||||
uint64_t num_records = xz_read_vli(index_buf, index_size, &pos);
|
|
||||||
if (num_records == UINT64_MAX || num_records == 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Sum uncompressed sizes across all records */
|
|
||||||
uint64_t total = 0;
|
|
||||||
for (uint64_t r = 0; r < num_records; r++) {
|
|
||||||
/* Unpadded Size (compressed) — skip it */
|
|
||||||
uint64_t unpadded = xz_read_vli(index_buf, index_size, &pos);
|
|
||||||
if (unpadded == UINT64_MAX || unpadded == 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
/* Uncompressed Size — accumulate */
|
|
||||||
uint64_t uncomp = xz_read_vli(index_buf, index_size, &pos);
|
|
||||||
if (uncomp == UINT64_MAX)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
total += uncomp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int64_t)total;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* 7-ZIP (.7z)
|
|
||||||
*
|
|
||||||
* Signature Header (32 bytes at offset 0):
|
|
||||||
* Offset Size Field
|
|
||||||
* 0 6 Signature (0x37 0x7A 0xBC 0xAF 0x27 0x1C)
|
|
||||||
* 6 1 Major version
|
|
||||||
* 7 1 Minor version
|
|
||||||
* 8 4 CRC32 of bytes 12..27
|
|
||||||
* 12 8 NextHeader Offset (uint64 LE, relative to offset 32)
|
|
||||||
* 20 8 NextHeader Size (uint64 LE)
|
|
||||||
* 28 4 NextHeader CRC32
|
|
||||||
*
|
|
||||||
* The End Header lives at file offset 32 + NextHeaderOffset.
|
|
||||||
* Its property-block stream (for a plain, non-encoded-header archive) is:
|
|
||||||
*
|
|
||||||
* kHeader (0x01)
|
|
||||||
* kMainStreamsInfo (0x04)
|
|
||||||
* kPackInfo (0x06)
|
|
||||||
* 7z-num: PackPos
|
|
||||||
* 7z-num: NumPackStreams
|
|
||||||
* kSize (0x09)
|
|
||||||
* NumPackStreams × 7z-num packed sizes
|
|
||||||
* kEnd (0x00)
|
|
||||||
* kUnPackInfo (0x07)
|
|
||||||
* kFolder (0x0b)
|
|
||||||
* 7z-num: NumFolders (must be 1 for single-file)
|
|
||||||
* byte: External (0 = inline folder data)
|
|
||||||
* [inline] 7z-num: NumCoders
|
|
||||||
* per coder:
|
|
||||||
* byte: flags (bits[3:0]=CodecIdSize, bit4=IsComplex, bit5=HasAttrs)
|
|
||||||
* CodecIdSize bytes: Codec ID
|
|
||||||
* if IsComplex: 7z-num NumInStreams, 7z-num NumOutStreams
|
|
||||||
* if HasAttrs: 7z-num AttrSize, AttrSize bytes Attributes
|
|
||||||
* [if NumCoders>1] BindPairs, PackedStreams (skipped here)
|
|
||||||
* kCodersUnPackSize (0x0c)
|
|
||||||
* 7z-num: uncompressed size ← what we want
|
|
||||||
* [optional kCRC (0x0a)]
|
|
||||||
* kEnd (0x00)
|
|
||||||
* [optional kSubStreamsInfo (0x08)]
|
|
||||||
* kEnd (0x00)
|
|
||||||
* [kFilesInfo (0x05) ...]
|
|
||||||
* kEnd (0x00)
|
|
||||||
*
|
|
||||||
* 7z variable-length number encoding:
|
|
||||||
* The first byte's leading 1-bits count how many extra bytes follow.
|
|
||||||
* extra=0 → value in bits[6:0] of first byte (7 bits)
|
|
||||||
* extra=1 → bits[5:0] of first byte + 8 bits of second (14 bits)
|
|
||||||
* ...
|
|
||||||
* extra=8 → 0xFF marker + full uint64 in next 8 bytes
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static const uint8_t SZ_SIG[6] = { 0x37,0x7A,0xBC,0xAF,0x27,0x1C };
|
|
||||||
|
|
||||||
#define SZ_kEnd 0x00u
|
|
||||||
#define SZ_kHeader 0x01u
|
|
||||||
#define SZ_kMainStreamsInfo 0x04u
|
|
||||||
#define SZ_kPackInfo 0x06u
|
|
||||||
#define SZ_kUnPackInfo 0x07u
|
|
||||||
#define SZ_kSize 0x09u
|
|
||||||
#define SZ_kFolder 0x0Bu
|
|
||||||
#define SZ_kCodersUnPackSize 0x0Cu
|
|
||||||
#define SZ_kEncodedHeader 0x17u
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode one 7z variable-length number from buf[*pos], advancing *pos.
|
|
||||||
*
|
|
||||||
* Algorithm from the 7-zip SDK (CPP/7zip/Archive/7z/7zIn.cpp ReadNumber):
|
|
||||||
* mask starts at 0x80 and shifts right each iteration.
|
|
||||||
* While (firstByte & mask) != 0: read one more byte into low bits of value.
|
|
||||||
* When the stop bit is found: add (firstByte & (mask-1)) into the
|
|
||||||
* appropriately shifted position.
|
|
||||||
*
|
|
||||||
* Returns UINT64_MAX on error (buffer overrun).
|
|
||||||
*/
|
|
||||||
static uint64_t sz_read_num(const uint8_t* buf, size_t buf_len, size_t* pos)
|
|
||||||
{
|
|
||||||
if (*pos >= buf_len) return UINT64_MAX;
|
|
||||||
|
|
||||||
uint8_t first = buf[(*pos)++];
|
|
||||||
uint8_t mask = 0x80u;
|
|
||||||
uint64_t value = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
|
||||||
if ((first & mask) == 0) {
|
|
||||||
/* Stop bit found: the remaining bits of first contribute here */
|
|
||||||
uint64_t high_part = first & (uint64_t)(mask - 1u);
|
|
||||||
value += high_part << (i * 8);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
/* Consume one more byte into bits [i*8 .. i*8+7] of value */
|
|
||||||
if (*pos >= buf_len) return UINT64_MAX;
|
|
||||||
value |= (uint64_t)buf[(*pos)++] << (i * 8);
|
|
||||||
mask = (uint8_t)(mask >> 1);
|
|
||||||
}
|
|
||||||
/* first == 0xFF: all 8 extra bytes consumed, value is complete */
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_7zip(int fd)
|
|
||||||
{
|
|
||||||
/* ---- Read & verify Signature Header (32 bytes) ---- */
|
|
||||||
uint8_t sig_hdr[32];
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, sig_hdr, 32))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (memcmp(sig_hdr, SZ_SIG, 6) != 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint64_t nh_offset = get_le64(sig_hdr + 12);
|
|
||||||
uint64_t nh_size = get_le64(sig_hdr + 20);
|
|
||||||
|
|
||||||
if (nh_size == 0 || nh_size > (uint64_t)64 * 1024 * 1024)
|
|
||||||
return DECOMP_SIZE_ERROR; /* sanity cap: 64 MiB */
|
|
||||||
|
|
||||||
/* ---- Read End Header ---- */
|
|
||||||
int64_t eh_abs = (int64_t)(32u + nh_offset);
|
|
||||||
if (lseek(fd, eh_abs, SEEK_SET) < 0) return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t* eh = (uint8_t*)
|
|
||||||
_alloca((size_t)nh_size);
|
|
||||||
if (read_exact(fd, eh, (size_t)nh_size)) return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
size_t pos = 0;
|
|
||||||
size_t len = (size_t)nh_size;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Helpers that operate on (eh, len, pos) in the enclosing scope.
|
|
||||||
* We avoid macros that embed do-while inside comma-expressions (not
|
|
||||||
* valid in C99); instead use explicit checks before each read.
|
|
||||||
*/
|
|
||||||
#define SZ_NEED(n) \
|
|
||||||
do { if (pos + (size_t)(n) > len) return DECOMP_SIZE_ERROR; } while (0)
|
|
||||||
#define SZ_BYTE(var) \
|
|
||||||
do { SZ_NEED(1); (var) = eh[pos++]; } while (0)
|
|
||||||
#define SZ_NUM(var) \
|
|
||||||
do { (var) = sz_read_num(eh, len, &pos); \
|
|
||||||
if ((var) == UINT64_MAX) return DECOMP_SIZE_ERROR; } while (0)
|
|
||||||
#define SZ_SKIP(n) \
|
|
||||||
do { SZ_NEED(n); pos += (size_t)(n); } while (0)
|
|
||||||
#define SZ_EXPECT(tag) \
|
|
||||||
do { uint8_t _b; SZ_BYTE(_b); \
|
|
||||||
if (_b != (tag)) return DECOMP_SIZE_ERROR; } while (0)
|
|
||||||
|
|
||||||
uint8_t first_tag;
|
|
||||||
uint64_t num_pack, num_folders, num_coders, unpack_size;
|
|
||||||
|
|
||||||
/* Expect kHeader */
|
|
||||||
SZ_EXPECT(SZ_kHeader);
|
|
||||||
|
|
||||||
/* kEncodedHeader (0x17) means the real header is itself compressed;
|
|
||||||
* that requires decompressing a sub-stream, which we do not support. */
|
|
||||||
SZ_NEED(1);
|
|
||||||
if (eh[pos] == SZ_kEncodedHeader)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
SZ_EXPECT(SZ_kMainStreamsInfo);
|
|
||||||
SZ_EXPECT(SZ_kPackInfo);
|
|
||||||
|
|
||||||
/* PackPos (discard) then NumPackStreams */
|
|
||||||
{ uint64_t dummy; SZ_NUM(dummy); (void)dummy; }
|
|
||||||
SZ_NUM(num_pack);
|
|
||||||
|
|
||||||
/* kSize: skip NumPackStreams packed-size VLIs */
|
|
||||||
SZ_EXPECT(SZ_kSize);
|
|
||||||
for (uint64_t i = 0; i < num_pack; i++) {
|
|
||||||
uint64_t dummy; SZ_NUM(dummy); (void)dummy;
|
|
||||||
}
|
|
||||||
SZ_EXPECT(SZ_kEnd); /* closes kPackInfo */
|
|
||||||
|
|
||||||
SZ_EXPECT(SZ_kUnPackInfo);
|
|
||||||
SZ_EXPECT(SZ_kFolder);
|
|
||||||
|
|
||||||
SZ_NUM(num_folders);
|
|
||||||
if (num_folders != 1)
|
|
||||||
return DECOMP_SIZE_ERROR; /* only single-folder archives supported */
|
|
||||||
|
|
||||||
{
|
|
||||||
uint8_t external; SZ_BYTE(external);
|
|
||||||
if (external != 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
} /* external not supported */
|
|
||||||
|
|
||||||
/* Parse the inline folder record to skip past coder descriptors */
|
|
||||||
SZ_NUM(num_coders);
|
|
||||||
if (num_coders == 0) return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
for (uint64_t c = 0; c < num_coders; c++) {
|
|
||||||
uint8_t flags;
|
|
||||||
SZ_BYTE(flags);
|
|
||||||
uint8_t id_size = flags & 0x0Fu;
|
|
||||||
int is_complex = (flags >> 4) & 1;
|
|
||||||
int has_attrs = (flags >> 5) & 1;
|
|
||||||
|
|
||||||
SZ_SKIP(id_size); /* Codec ID bytes */
|
|
||||||
|
|
||||||
if (is_complex) {
|
|
||||||
uint64_t dummy;
|
|
||||||
SZ_NUM(dummy); (void)dummy; /* NumInStreams */
|
|
||||||
SZ_NUM(dummy); (void)dummy; /* NumOutStreams */
|
|
||||||
}
|
|
||||||
if (has_attrs) {
|
|
||||||
uint64_t attr_size; SZ_NUM(attr_size);
|
|
||||||
SZ_SKIP(attr_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Multi-coder folders have BindPairs and possibly PackedStreams indices */
|
|
||||||
if (num_coders > 1) {
|
|
||||||
for (uint64_t i = 0; i < num_coders - 1; i++) {
|
|
||||||
uint64_t dummy;
|
|
||||||
SZ_NUM(dummy); (void)dummy; /* InIndex */
|
|
||||||
SZ_NUM(dummy); (void)dummy; /* OutIndex */
|
|
||||||
}
|
|
||||||
if (num_pack > num_coders - 1) {
|
|
||||||
uint64_t n = num_pack - (num_coders - 1);
|
|
||||||
for (uint64_t i = 0; i < n; i++) {
|
|
||||||
uint64_t dummy; SZ_NUM(dummy); (void)dummy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* kCodersUnPackSize: one VLI per output stream (single folder → one value) */
|
|
||||||
SZ_NEED(1);
|
|
||||||
first_tag = eh[pos++];
|
|
||||||
if (first_tag != SZ_kCodersUnPackSize) return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
SZ_NUM(unpack_size);
|
|
||||||
return (int64_t)unpack_size;
|
|
||||||
|
|
||||||
#undef SZ_NEED
|
|
||||||
#undef SZ_BYTE
|
|
||||||
#undef SZ_NUM
|
|
||||||
#undef SZ_SKIP
|
|
||||||
#undef SZ_EXPECT
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* Ventoy Sparse Image (.vsti)
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_vtsi(int fd)
|
|
||||||
{
|
|
||||||
if (lseek(fd, -512 + 8 + 4, SEEK_END) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t isize[8];
|
|
||||||
if (read_exact(fd, isize, 8))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
return (int64_t)get_le64(isize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------
|
|
||||||
* Zstandard (.zst)
|
|
||||||
*
|
|
||||||
* Frame layout:
|
|
||||||
* Offset Size Field
|
|
||||||
* 0 4 Magic (0xFD2FB528, LE)
|
|
||||||
* 4 1 Frame Header Descriptor (FHD)
|
|
||||||
* 5 0/1 Window_Descriptor (absent when Single_Segment_Flag set)
|
|
||||||
* ? 0/1/2/4/8 Content_Size
|
|
||||||
*
|
|
||||||
* FHD bits:
|
|
||||||
* [7:6] Frame_Content_Size_Flag (FCS_Flag)
|
|
||||||
* [5] Single_Segment_Flag (SS_Flag)
|
|
||||||
* [4] reserved (must be 0)
|
|
||||||
* [3] Content_Checksum_Flag
|
|
||||||
* [2] reserved (must be 0)
|
|
||||||
* [1:0] Dictionary_ID_Flag
|
|
||||||
*
|
|
||||||
* Content_Size size from FCS_Flag:
|
|
||||||
* 0 → 0 bytes if SS_Flag==0 (unknown), or 1 byte if SS_Flag==1
|
|
||||||
* 1 → 2 bytes (value + 256, to avoid overlap with 1-byte encoding)
|
|
||||||
* 2 → 4 bytes
|
|
||||||
* 3 → 8 bytes
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
#define ZSTD_MAGIC UINT32_C(0xFD2FB528)
|
|
||||||
#define ZSTD_MAGIC_SIZE 4
|
|
||||||
|
|
||||||
static int64_t get_uncompress_size_zstd(int fd)
|
|
||||||
{
|
|
||||||
uint8_t buf[4 + 1 + 1]; /* magic + FHD + optional Window_Descriptor */
|
|
||||||
|
|
||||||
if (lseek(fd, 0, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
if (read_exact(fd, buf, 6))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
if (get_le32(buf) != ZSTD_MAGIC)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t fhd = buf[4];
|
|
||||||
int fcs_flag = (fhd >> 6) & 0x03;
|
|
||||||
int ss_flag = (fhd >> 5) & 0x01;
|
|
||||||
|
|
||||||
/* Window_Descriptor is present only when Single_Segment_Flag == 0.
|
|
||||||
* buf[5] already consumed it; if SS_Flag==1 that byte is Content_Size[0].
|
|
||||||
* We'll re-seek to the correct offset to avoid confusion. */
|
|
||||||
|
|
||||||
/* Determine Content_Size field size. */
|
|
||||||
int cs_bytes;
|
|
||||||
if (fcs_flag == 0) {
|
|
||||||
if (ss_flag == 0)
|
|
||||||
return DECOMP_SIZE_UNKNOWN; /* field absent */
|
|
||||||
cs_bytes = 1;
|
|
||||||
} else if (fcs_flag == 1) {
|
|
||||||
cs_bytes = 2;
|
|
||||||
} else if (fcs_flag == 2) {
|
|
||||||
cs_bytes = 4;
|
|
||||||
} else {
|
|
||||||
cs_bytes = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Content_Size starts at:
|
|
||||||
* offset 5 if Single_Segment_Flag == 1 (no Window_Descriptor)
|
|
||||||
* offset 6 if Single_Segment_Flag == 0 (Window_Descriptor present)
|
|
||||||
*/
|
|
||||||
int64_t cs_offset = (ss_flag ? 5 : 6);
|
|
||||||
|
|
||||||
if (lseek(fd, cs_offset, SEEK_SET) < 0)
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint8_t cs_buf[8] = { 0 };
|
|
||||||
if (read_exact(fd, cs_buf, (size_t)cs_bytes))
|
|
||||||
return DECOMP_SIZE_ERROR;
|
|
||||||
|
|
||||||
uint64_t size;
|
|
||||||
switch (cs_bytes) {
|
|
||||||
case 1:
|
|
||||||
size = cs_buf[0];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
/*
|
|
||||||
* 2-byte encoding: actual value = field_value + 256
|
|
||||||
* (reserves 0-255 for the 1-byte SS_Flag path)
|
|
||||||
*/
|
|
||||||
size = (uint64_t)get_le16(cs_buf) + 256U;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
size = get_le32(cs_buf);
|
|
||||||
break;
|
|
||||||
default: /* 8 */
|
|
||||||
size = get_le64(cs_buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int64_t)size;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(BLED_EXPECT_DISK_IMAGE)
|
|
||||||
extern progress_t bled_progress;
|
|
||||||
extern unpacker_t unpacker[BLED_COMPRESSION_MAX];
|
|
||||||
int64_t get_uncompressed_size_from_disk_image(int fd, int type)
|
|
||||||
{
|
|
||||||
progress_t old_bled_progress = bled_progress;
|
|
||||||
int64_t size = DECOMP_SIZE_UNKNOWN;
|
|
||||||
uint8_t buf[8192];
|
|
||||||
transformer_state_t xstate;
|
|
||||||
|
|
||||||
bled_progress = NULL; /* Can't have progress on this operation */
|
|
||||||
init_transformer_state(&xstate);
|
|
||||||
xstate.src_fd = fd;
|
|
||||||
xstate.dst_fd = -1;
|
|
||||||
xstate.mem_output_buf = buf;
|
|
||||||
xstate.mem_output_size = 0;
|
|
||||||
xstate.mem_output_size_max = sizeof(buf);
|
|
||||||
|
|
||||||
if (setjmp(bb_error_jmp))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
|
||||||
size = unpacker[type](&xstate);
|
|
||||||
if (size != sizeof(buf) || buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) {
|
|
||||||
size = DECOMP_SIZE_UNKNOWN;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (buf[0x1be] == 0x00 && buf[0x1c2] == 0xee) {
|
|
||||||
/*
|
|
||||||
* Protective EFI MBR => look for the primary GPT, which'll also give us the sector size
|
|
||||||
* The address of the backup GPT is assumed to be the last LBA for the disk
|
|
||||||
*/
|
|
||||||
if (memcmp("EFI PART", &buf[0x200], 8) == 0)
|
|
||||||
size = (get_le64(&buf[0x220]) + 1) * 512;
|
|
||||||
else if (memcmp("EFI PART", &buf[0x1000], 8) == 0)
|
|
||||||
size = (get_le64(&buf[0x1020]) + 1) * 4096;
|
|
||||||
else
|
|
||||||
bb_error_msg("Could not locate primary GPT");
|
|
||||||
} else if (buf[0x1be] == 0x80) {
|
|
||||||
/* Regular bootable MBR => compute the max LBA (using primary partitions only) */
|
|
||||||
uint32_t max_lba = 1;
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
max_lba = MAX(max_lba, get_le32(&buf[0x1be + 0x10 * i + 8]) + get_le32(&buf[0x1be + 0x10 * i + 0xc]));
|
|
||||||
size = (max_lba + 1) * 512; /* assume 512-byte sectors for anything MBR based */
|
|
||||||
if (size < 4096)
|
|
||||||
size = DECOMP_SIZE_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
bled_progress = old_bled_progress;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static get_uncompressed_size_t _get_uncompressed_size[BLED_COMPRESSION_MAX] = {
|
|
||||||
get_uncompress_size_none,
|
|
||||||
get_uncompress_size_zip,
|
|
||||||
get_uncompress_size_none, // .Z has no decompressed size info
|
|
||||||
get_uncompress_size_gz,
|
|
||||||
get_uncompress_size_lzma,
|
|
||||||
get_uncompress_size_none, // .bz2 has no decompressed size info
|
|
||||||
get_uncompress_size_xz,
|
|
||||||
get_uncompress_size_7zip,
|
|
||||||
get_uncompress_size_vtsi,
|
|
||||||
get_uncompress_size_zstd,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Get the decompressed size of file 'fd', compressed using 'type' */
|
|
||||||
int64_t get_uncompressed_size(int fd, int type)
|
|
||||||
{
|
|
||||||
int64_t size = _get_uncompressed_size[type](fd);
|
|
||||||
#if defined(BLED_EXPECT_DISK_IMAGE)
|
|
||||||
if (size < 0)
|
|
||||||
size = get_uncompressed_size_from_disk_image(fd, type);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Make sure to reset our file pointer */
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
@ -768,7 +768,7 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||||
if (check_signature16(xstate, BZIP2_MAGIC))
|
if (check_signature16(xstate, BZIP2_MAGIC))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
outbuf = aligned_xmalloc(IOBUF_SIZE);
|
outbuf = xmalloc(IOBUF_SIZE);
|
||||||
if (outbuf == NULL)
|
if (outbuf == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
@ -834,7 +834,7 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
||||||
|
|
||||||
release_mem:
|
release_mem:
|
||||||
dealloc_bunzip(bd);
|
dealloc_bunzip(bd);
|
||||||
aligned_free(outbuf);
|
free(outbuf);
|
||||||
|
|
||||||
return i ? i : IF_DESKTOP(total_written) + 0;
|
return i ? i : IF_DESKTOP(total_written) + 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1012,7 +1012,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||||
ssize_t nwrote;
|
ssize_t nwrote;
|
||||||
|
|
||||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||||
gunzip_window = aligned_xzalloc(GUNZIP_WSIZE);
|
gunzip_window = xzalloc(GUNZIP_WSIZE);
|
||||||
gunzip_outbuf_count = 0;
|
gunzip_outbuf_count = 0;
|
||||||
gunzip_bytes_out = 0;
|
gunzip_bytes_out = 0;
|
||||||
gunzip_src_fd = xstate->src_fd;
|
gunzip_src_fd = xstate->src_fd;
|
||||||
|
|
@ -1068,7 +1068,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
||||||
}
|
}
|
||||||
ret:
|
ret:
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
aligned_free(gunzip_window);
|
free(gunzip_window);
|
||||||
free(gunzip_crc_table);
|
free(gunzip_crc_table);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
inbuf = xzalloc(IBUFSIZ + 64);
|
inbuf = xzalloc(IBUFSIZ + 64);
|
||||||
outbuf = aligned_xzalloc(OBUFSIZ + 2048);
|
outbuf = xzalloc(OBUFSIZ + 2048);
|
||||||
htab = xzalloc(HSIZE); /* wasn't zeroed out before, maybe can xmalloc? */
|
htab = xzalloc(HSIZE); /* wasn't zeroed out before, maybe can xmalloc? */
|
||||||
codetab = xzalloc(HSIZE * sizeof(codetab[0]));
|
codetab = xzalloc(HSIZE * sizeof(codetab[0]));
|
||||||
|
|
||||||
|
|
@ -311,7 +311,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
||||||
retval = IF_DESKTOP(total_written) + 0;
|
retval = IF_DESKTOP(total_written) + 0;
|
||||||
err:
|
err:
|
||||||
free(inbuf);
|
free(inbuf);
|
||||||
aligned_free(outbuf);
|
free(outbuf);
|
||||||
free(htab);
|
free(htab);
|
||||||
free(codetab);
|
free(codetab);
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
||||||
|
|
@ -263,8 +263,8 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||||
if (header.dict_size == 0)
|
if (header.dict_size == 0)
|
||||||
header.dict_size++;
|
header.dict_size++;
|
||||||
|
|
||||||
buffer_size = (uint32_t)MAX(SECTOR_ALIGNMENT, MIN(header.dst_size, header.dict_size));
|
buffer_size = (uint32_t)MIN(header.dst_size, header.dict_size);
|
||||||
buffer = aligned_xmalloc(buffer_size);
|
buffer = xmalloc(buffer_size);
|
||||||
|
|
||||||
{
|
{
|
||||||
int num_probs;
|
int num_probs;
|
||||||
|
|
@ -528,7 +528,7 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
||||||
}
|
}
|
||||||
rc_free(rc);
|
rc_free(rc);
|
||||||
free(p);
|
free(p);
|
||||||
aligned_free(buffer);
|
free(buffer);
|
||||||
return total_written;
|
return total_written;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_xz_stream(transformer_state_t *xstate
|
||||||
bb_error_msg_and_err("memory allocation error");
|
bb_error_msg_and_err("memory allocation error");
|
||||||
|
|
||||||
in = xmalloc(XZ_BUFSIZE);
|
in = xmalloc(XZ_BUFSIZE);
|
||||||
out = aligned_xmalloc(XZ_BUFSIZE);
|
out = xmalloc(XZ_BUFSIZE);
|
||||||
|
|
||||||
b.in = in;
|
b.in = in;
|
||||||
b.in_pos = 0;
|
b.in_pos = 0;
|
||||||
|
|
@ -129,7 +129,7 @@ out:
|
||||||
err:
|
err:
|
||||||
xz_dec_end(s);
|
xz_dec_end(s);
|
||||||
free(in);
|
free(in);
|
||||||
aligned_free(out);
|
free(out);
|
||||||
if (ret == XZ_OK)
|
if (ret == XZ_OK)
|
||||||
return n;
|
return n;
|
||||||
else if (ret == XZ_BUF_FULL)
|
else if (ret == XZ_BUF_FULL)
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@ static void unzip_set_xstate(transformer_state_t* xstate, zip_header_t* zip)
|
||||||
zip64_t* zip64;
|
zip64_t* zip64;
|
||||||
|
|
||||||
/* Set the default sizes for non ZIP64 content */
|
/* Set the default sizes for non ZIP64 content */
|
||||||
xstate->bytes_total = zip->fmt.ucmpsize;
|
xstate->dst_size = zip->fmt.ucmpsize;
|
||||||
xstate->bytes_in = zip->fmt.cmpsize;
|
xstate->bytes_in = zip->fmt.cmpsize;
|
||||||
|
|
||||||
/* Set the filename */
|
/* Set the filename */
|
||||||
|
|
@ -440,7 +440,7 @@ static void unzip_set_xstate(transformer_state_t* xstate, zip_header_t* zip)
|
||||||
zip64->fmt.cmpsize,
|
zip64->fmt.cmpsize,
|
||||||
zip64->fmt.ucmpsize
|
zip64->fmt.ucmpsize
|
||||||
);
|
);
|
||||||
xstate->bytes_total = zip64->fmt.ucmpsize;
|
xstate->dst_size = zip64->fmt.ucmpsize;
|
||||||
xstate->bytes_in = zip64->fmt.cmpsize;
|
xstate->bytes_in = zip64->fmt.cmpsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -457,10 +457,10 @@ unzip_extract(zip_header_t* zip, transformer_state_t* xstate)
|
||||||
|
|
||||||
if (zip->fmt.method == 0) {
|
if (zip->fmt.method == 0) {
|
||||||
/* Method 0 - stored (not compressed) */
|
/* Method 0 - stored (not compressed) */
|
||||||
if (xstate->bytes_total) {
|
if (xstate->dst_size) {
|
||||||
bb_copyfd_exact_size(xstate->src_fd, xstate->dst_fd, xstate->bytes_total);
|
bb_copyfd_exact_size(xstate->src_fd, xstate->dst_fd, xstate->dst_size);
|
||||||
}
|
}
|
||||||
return xstate->bytes_total;
|
return xstate->dst_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zip->fmt.method == 8) {
|
if (zip->fmt.method == 8) {
|
||||||
|
|
@ -507,7 +507,7 @@ unzip_extract(zip_header_t* zip, transformer_state_t* xstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate decompression - size */
|
/* Validate decompression - size */
|
||||||
if (n != -ENOSPC && xstate->bytes_total != xstate->bytes_out) {
|
if (n != -ENOSPC && xstate->dst_size != xstate->bytes_out) {
|
||||||
/* Don't die. Who knows, maybe len calculation
|
/* Don't die. Who knows, maybe len calculation
|
||||||
* was botched somewhere. After all, crc matched! */
|
* was botched somewhere. After all, crc matched! */
|
||||||
bb_simple_error_msg("bad length");
|
bb_simple_error_msg("bad length");
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ unpack_zstd_stream_inner(transformer_state_t *xstate,
|
||||||
ZSTD_DStream *dctx, void *out_buff)
|
ZSTD_DStream *dctx, void *out_buff)
|
||||||
{
|
{
|
||||||
const U32 zstd_magic = ZSTD_MAGIC;
|
const U32 zstd_magic = ZSTD_MAGIC;
|
||||||
const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), SECTOR_ALIGNMENT),
|
const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), 1024),
|
||||||
out_allocsize = roundupsize(ZSTD_DStreamOutSize(), SECTOR_ALIGNMENT);
|
out_allocsize = roundupsize(ZSTD_DStreamOutSize(), 1024);
|
||||||
|
|
||||||
IF_DESKTOP(long long int total = 0;)
|
IF_DESKTOP(long long int total = 0;)
|
||||||
size_t last_result = ZSTD_error_maxCode + 1;
|
size_t last_result = ZSTD_error_maxCode + 1;
|
||||||
|
|
@ -119,8 +119,8 @@ unpack_zstd_stream_inner(transformer_state_t *xstate,
|
||||||
IF_DESKTOP(long long) int FAST_FUNC
|
IF_DESKTOP(long long) int FAST_FUNC
|
||||||
unpack_zstd_stream(transformer_state_t *xstate)
|
unpack_zstd_stream(transformer_state_t *xstate)
|
||||||
{
|
{
|
||||||
const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), SECTOR_ALIGNMENT),
|
const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), 1024),
|
||||||
out_allocsize = roundupsize(ZSTD_DStreamOutSize(), SECTOR_ALIGNMENT);
|
out_allocsize = roundupsize(ZSTD_DStreamOutSize(), 1024);
|
||||||
|
|
||||||
IF_DESKTOP(long long) int result;
|
IF_DESKTOP(long long) int result;
|
||||||
void *out_buff;
|
void *out_buff;
|
||||||
|
|
@ -132,10 +132,10 @@ unpack_zstd_stream(transformer_state_t *xstate)
|
||||||
bb_error_msg_and_die("memory exhausted");
|
bb_error_msg_and_die("memory exhausted");
|
||||||
}
|
}
|
||||||
|
|
||||||
out_buff = aligned_xmalloc(in_allocsize + out_allocsize);
|
out_buff = xmalloc(in_allocsize + out_allocsize);
|
||||||
|
|
||||||
result = unpack_zstd_stream_inner(xstate, dctx, out_buff);
|
result = unpack_zstd_stream_inner(xstate, dctx, out_buff);
|
||||||
aligned_free(out_buff);
|
free(out_buff);
|
||||||
ZSTD_freeDStream(dctx);
|
ZSTD_freeDStream(dctx);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ typedef struct {
|
||||||
|
|
||||||
extern int __static_assert__[sizeof(VTSI_FOOTER) == 512 ? 1 : -1];
|
extern int __static_assert__[sizeof(VTSI_FOOTER) == 512 ? 1 : -1];
|
||||||
|
|
||||||
#define MAX_READ_BUF BB_BUFSIZE
|
#define MAX_READ_BUF (8 * 1024 * 1024)
|
||||||
|
|
||||||
static int check_vtsi_footer(VTSI_FOOTER* footer)
|
static int check_vtsi_footer(VTSI_FOOTER* footer)
|
||||||
{
|
{
|
||||||
|
|
@ -140,13 +140,13 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_vtsi_stream(transformer_state_t* xsta
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (xstate->mem_output_size_max == 512)
|
if (xstate->mem_output_size_max == 512)
|
||||||
max_buflen = SECTOR_ALIGNMENT;
|
max_buflen = 1024;
|
||||||
|
|
||||||
buf = aligned_xmalloc(max_buflen + footer.segment_num * sizeof(VTSI_SEGMENT));
|
segment = xmalloc(footer.segment_num * sizeof(VTSI_SEGMENT) + max_buflen);
|
||||||
if (!buf)
|
if (!segment)
|
||||||
bb_error_msg_and_err("Failed to alloc segment buffer %u", footer.segment_num);
|
bb_error_msg_and_err("Failed to alloc segment buffer %u", footer.segment_num);
|
||||||
|
|
||||||
segment = (VTSI_SEGMENT*)&buf[max_buflen];
|
buf = (uint8_t*)segment + footer.segment_num * sizeof(VTSI_SEGMENT);
|
||||||
|
|
||||||
lseek(src_fd, footer.segment_offset, SEEK_SET);
|
lseek(src_fd, footer.segment_offset, SEEK_SET);
|
||||||
safe_read(src_fd, segment, footer.segment_num * sizeof(VTSI_SEGMENT));
|
safe_read(src_fd, segment, footer.segment_num * sizeof(VTSI_SEGMENT));
|
||||||
|
|
@ -182,7 +182,8 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_vtsi_stream(transformer_state_t* xsta
|
||||||
n = tot;
|
n = tot;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
aligned_free(buf);
|
if (segment)
|
||||||
|
free(segment);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
@ -41,7 +40,6 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#define ONE_TB 1099511627776ULL
|
#define ONE_TB 1099511627776ULL
|
||||||
#define SECTOR_ALIGNMENT 4096
|
|
||||||
|
|
||||||
#define ENABLE_DESKTOP 1
|
#define ENABLE_DESKTOP 1
|
||||||
#if ENABLE_DESKTOP
|
#if ENABLE_DESKTOP
|
||||||
|
|
@ -126,7 +124,6 @@ extern jmp_buf bb_error_jmp;
|
||||||
extern char* bb_virtual_buf;
|
extern char* bb_virtual_buf;
|
||||||
extern size_t bb_virtual_len, bb_virtual_pos;
|
extern size_t bb_virtual_len, bb_virtual_pos;
|
||||||
extern int bb_virtual_fd;
|
extern int bb_virtual_fd;
|
||||||
extern bool bb_progress_on_write;
|
|
||||||
|
|
||||||
uint32_t* crc32_filltable(uint32_t *crc_table, int endian);
|
uint32_t* crc32_filltable(uint32_t *crc_table, int endian);
|
||||||
uint32_t crc32_le(uint32_t crc, unsigned char const *p, size_t len, uint32_t *crc32table_le);
|
uint32_t crc32_le(uint32_t crc, unsigned char const *p, size_t len, uint32_t *crc32table_le);
|
||||||
|
|
@ -155,7 +152,7 @@ struct timeval64 {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void (*bled_printf) (const char* format, ...);
|
extern void (*bled_printf) (const char* format, ...);
|
||||||
extern void (*bled_progress) (const int64_t processed_bytes);
|
extern void (*bled_progress) (const uint64_t processed_bytes);
|
||||||
extern void (*bled_switch) (const char* filename, const uint64_t filesize);
|
extern void (*bled_switch) (const char* filename, const uint64_t filesize);
|
||||||
extern int (*bled_read)(int fd, void* buf, unsigned int count);
|
extern int (*bled_read)(int fd, void* buf, unsigned int count);
|
||||||
extern int (*bled_write)(int fd, const void* buf, unsigned int count);
|
extern int (*bled_write)(int fd, const void* buf, unsigned int count);
|
||||||
|
|
@ -194,8 +191,8 @@ static inline int fnmatch(const char *pattern, const char *string, int flags) {
|
||||||
static inline pid_t wait(int* status) { *status = 4; return -1; }
|
static inline pid_t wait(int* status) { *status = 4; return -1; }
|
||||||
#define wait_any_nohang wait
|
#define wait_any_nohang wait
|
||||||
|
|
||||||
/* This enables the display of a progress based on the number of bytes read/written */
|
/* This enables the display of a progress based on the number of bytes read */
|
||||||
extern uint64_t bb_total_rb, bb_total_wb;
|
extern uint64_t bb_total_rb;
|
||||||
static inline int full_read(int fd, void *buf, unsigned int count) {
|
static inline int full_read(int fd, void *buf, unsigned int count) {
|
||||||
int rb;
|
int rb;
|
||||||
|
|
||||||
|
|
@ -226,8 +223,9 @@ static inline int full_read(int fd, void *buf, unsigned int count) {
|
||||||
} else {
|
} else {
|
||||||
rb = (bled_read != NULL) ? bled_read(fd, buf, count) : _read(fd, buf, count);
|
rb = (bled_read != NULL) ? bled_read(fd, buf, count) : _read(fd, buf, count);
|
||||||
}
|
}
|
||||||
if (bled_progress != NULL && !bb_progress_on_write && rb > 0) {
|
if (rb > 0) {
|
||||||
bb_total_rb += rb;
|
bb_total_rb += rb;
|
||||||
|
if (bled_progress != NULL)
|
||||||
bled_progress(bb_total_rb);
|
bled_progress(bb_total_rb);
|
||||||
}
|
}
|
||||||
return rb;
|
return rb;
|
||||||
|
|
@ -235,19 +233,13 @@ static inline int full_read(int fd, void *buf, unsigned int count) {
|
||||||
|
|
||||||
static inline int full_write(int fd, const void* buffer, unsigned int count)
|
static inline int full_write(int fd, const void* buffer, unsigned int count)
|
||||||
{
|
{
|
||||||
int wb;
|
|
||||||
/* None of our r/w buffers should be larger than BB_BUFSIZE */
|
/* None of our r/w buffers should be larger than BB_BUFSIZE */
|
||||||
if (count > BB_BUFSIZE) {
|
if (count > BB_BUFSIZE) {
|
||||||
errno = E2BIG;
|
errno = E2BIG;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wb = (bled_write != NULL) ? bled_write(fd, buffer, count) : _write(fd, buffer, count);
|
return (bled_write != NULL) ? bled_write(fd, buffer, count) : _write(fd, buffer, count);
|
||||||
if (bled_progress != NULL && bb_progress_on_write && wb > 0) {
|
|
||||||
bb_total_wb += wb;
|
|
||||||
bled_progress(bb_total_wb);
|
|
||||||
}
|
|
||||||
return wb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
||||||
|
|
@ -262,7 +254,7 @@ static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
||||||
if (size > ONE_TB)
|
if (size > ONE_TB)
|
||||||
bb_error_msg_and_die("too large");
|
bb_error_msg_and_die("too large");
|
||||||
|
|
||||||
buf = _mm_malloc(BB_BUFSIZE, SECTOR_ALIGNMENT);
|
buf = malloc(BB_BUFSIZE);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
bb_error_msg_and_die("out of memory");
|
bb_error_msg_and_die("out of memory");
|
||||||
|
|
||||||
|
|
@ -270,7 +262,7 @@ static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
||||||
int r, w;
|
int r, w;
|
||||||
r = full_read(fd1, buf, (unsigned int)MIN(size - rb, BB_BUFSIZE));
|
r = full_read(fd1, buf, (unsigned int)MIN(size - rb, BB_BUFSIZE));
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
_mm_free(buf);
|
free(buf);
|
||||||
bb_error_msg_and_die("read error");
|
bb_error_msg_and_die("read error");
|
||||||
}
|
}
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
|
|
@ -279,7 +271,7 @@ static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
||||||
}
|
}
|
||||||
w = full_write(fd2, buf, r);
|
w = full_write(fd2, buf, r);
|
||||||
if (w < 0) {
|
if (w < 0) {
|
||||||
_mm_free(buf);
|
free(buf);
|
||||||
bb_error_msg_and_die("write error");
|
bb_error_msg_and_die("write error");
|
||||||
}
|
}
|
||||||
if (w != r) {
|
if (w != r) {
|
||||||
|
|
@ -288,7 +280,7 @@ static inline void bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
||||||
}
|
}
|
||||||
rb += r;
|
rb += r;
|
||||||
}
|
}
|
||||||
_mm_free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct tm *localtime_r(const time_t *timep, struct tm *result) {
|
static inline struct tm *localtime_r(const time_t *timep, struct tm *result) {
|
||||||
|
|
@ -302,9 +294,6 @@ static inline struct tm *localtime_r(const time_t *timep, struct tm *result) {
|
||||||
#define xmalloc malloc
|
#define xmalloc malloc
|
||||||
#define xzalloc(x) calloc(x, 1)
|
#define xzalloc(x) calloc(x, 1)
|
||||||
#define malloc_or_warn malloc
|
#define malloc_or_warn malloc
|
||||||
#define aligned_xmalloc(x) _mm_malloc(x, SECTOR_ALIGNMENT);
|
|
||||||
static inline void* aligned_xzalloc(size_t x) { void* r = aligned_xmalloc(x); if (r) memset(r, 0, x); return r; }
|
|
||||||
#define aligned_free _mm_free
|
|
||||||
#define mkdir(x, y) _mkdirU(x)
|
#define mkdir(x, y) _mkdirU(x)
|
||||||
struct fd_pair { int rd; int wr; };
|
struct fd_pair { int rd; int wr; };
|
||||||
void xpipe(int filedes[2]) FAST_FUNC;
|
void xpipe(int filedes[2]) FAST_FUNC;
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,7 @@ static enum xz_ret XZ_FUNC crc32_validate(struct xz_dec *s, struct xz_buf *b)
|
||||||
*/
|
*/
|
||||||
static bool XZ_FUNC check_skip(struct xz_dec *s, struct xz_buf *b)
|
static bool XZ_FUNC check_skip(struct xz_dec *s, struct xz_buf *b)
|
||||||
{
|
{
|
||||||
while (s->check_type >= 0 && s->check_type < 16 && s->pos < check_sizes[s->check_type]) {
|
while (s->check_type < 16 && s->pos < check_sizes[s->check_type]) {
|
||||||
if (b->in_pos == b->in_size)
|
if (b->in_pos == b->in_size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
1
src/db.h
1
src/db.h
|
|
@ -84,7 +84,6 @@ static uint8_t sha256db[] = {
|
||||||
0x82, 0x11, 0xfa, 0xe8, 0xaf, 0xf0, 0x23, 0x3f, 0x05, 0xa8, 0xb7, 0x8c, 0x58, 0x15, 0x25, 0xe2, 0x81, 0xac, 0x98, 0x23, 0x54, 0xa8, 0xc4, 0x3b, 0xb4, 0x96, 0x5e, 0x61, 0xdc, 0x98, 0xb4, 0x62, // syslinux-6.03/pre8/ldlinux.bss
|
0x82, 0x11, 0xfa, 0xe8, 0xaf, 0xf0, 0x23, 0x3f, 0x05, 0xa8, 0xb7, 0x8c, 0x58, 0x15, 0x25, 0xe2, 0x81, 0xac, 0x98, 0x23, 0x54, 0xa8, 0xc4, 0x3b, 0xb4, 0x96, 0x5e, 0x61, 0xdc, 0x98, 0xb4, 0x62, // syslinux-6.03/pre8/ldlinux.bss
|
||||||
0x83, 0x57, 0xaa, 0xd3, 0x6a, 0xec, 0x68, 0x21, 0xcb, 0xf2, 0x17, 0x4d, 0xb5, 0xd2, 0x09, 0xef, 0x2c, 0xd2, 0x62, 0x88, 0x12, 0x39, 0xeb, 0xc3, 0xf4, 0xc1, 0xcf, 0x55, 0xab, 0x10, 0xee, 0x55, // grub-2.12~rc1/core.img
|
0x83, 0x57, 0xaa, 0xd3, 0x6a, 0xec, 0x68, 0x21, 0xcb, 0xf2, 0x17, 0x4d, 0xb5, 0xd2, 0x09, 0xef, 0x2c, 0xd2, 0x62, 0x88, 0x12, 0x39, 0xeb, 0xc3, 0xf4, 0xc1, 0xcf, 0x55, 0xab, 0x10, 0xee, 0x55, // grub-2.12~rc1/core.img
|
||||||
0x83, 0x9b, 0xd0, 0x8a, 0xcb, 0x68, 0x47, 0xd6, 0x55, 0x07, 0xf1, 0x4e, 0x7a, 0x55, 0x6e, 0x91, 0xe6, 0x12, 0x9c, 0x47, 0x86, 0x3f, 0x7d, 0x61, 0xe2, 0xce, 0x6d, 0xb7, 0x8d, 0xf3, 0xd2, 0x3f, // syslinux-6.03/pre9/ldlinux.bss
|
0x83, 0x9b, 0xd0, 0x8a, 0xcb, 0x68, 0x47, 0xd6, 0x55, 0x07, 0xf1, 0x4e, 0x7a, 0x55, 0x6e, 0x91, 0xe6, 0x12, 0x9c, 0x47, 0x86, 0x3f, 0x7d, 0x61, 0xe2, 0xce, 0x6d, 0xb7, 0x8d, 0xf3, 0xd2, 0x3f, // syslinux-6.03/pre9/ldlinux.bss
|
||||||
0x84, 0x73, 0x50, 0x4a, 0x84, 0x9c, 0x89, 0x83, 0x29, 0xcb, 0x90, 0x92, 0xf2, 0x5e, 0x26, 0x9d, 0x4e, 0x19, 0x3b, 0xc7, 0x72, 0xf8, 0x48, 0x9f, 0xa2, 0xc5, 0xd5, 0xa5, 0xd2, 0xd8, 0x87, 0x74, // grub-2.12-nonstandard-gdie/core.img
|
|
||||||
0x87, 0xaa, 0x91, 0xf8, 0x7f, 0xba, 0x5f, 0x31, 0x79, 0x43, 0x08, 0xda, 0xa4, 0xa4, 0x8d, 0xad, 0x6c, 0xf6, 0xfa, 0x34, 0x26, 0x4d, 0x66, 0xb8, 0x84, 0xb8, 0xb9, 0xdc, 0x96, 0x42, 0xed, 0x86, // syslinux-5.02/ldlinux.sys
|
0x87, 0xaa, 0x91, 0xf8, 0x7f, 0xba, 0x5f, 0x31, 0x79, 0x43, 0x08, 0xda, 0xa4, 0xa4, 0x8d, 0xad, 0x6c, 0xf6, 0xfa, 0x34, 0x26, 0x4d, 0x66, 0xb8, 0x84, 0xb8, 0xb9, 0xdc, 0x96, 0x42, 0xed, 0x86, // syslinux-5.02/ldlinux.sys
|
||||||
0x88, 0x14, 0xe5, 0x76, 0xab, 0xc1, 0xaa, 0x44, 0xdd, 0xe9, 0x43, 0xb0, 0xca, 0xae, 0xe8, 0x33, 0xa5, 0x81, 0x01, 0x42, 0x61, 0x4a, 0xde, 0xeb, 0x4c, 0xc7, 0x25, 0xe7, 0x8a, 0x50, 0x45, 0xb7, // syslinux-6.03/ldlinux.bss
|
0x88, 0x14, 0xe5, 0x76, 0xab, 0xc1, 0xaa, 0x44, 0xdd, 0xe9, 0x43, 0xb0, 0xca, 0xae, 0xe8, 0x33, 0xa5, 0x81, 0x01, 0x42, 0x61, 0x4a, 0xde, 0xeb, 0x4c, 0xc7, 0x25, 0xe7, 0x8a, 0x50, 0x45, 0xb7, // syslinux-6.03/ldlinux.bss
|
||||||
0x8b, 0x93, 0x7e, 0x5e, 0x8b, 0xae, 0x5a, 0xf8, 0xc8, 0x95, 0x63, 0xc0, 0x0e, 0x9c, 0xaf, 0xc6, 0xcd, 0x7c, 0x2c, 0x80, 0x8a, 0xda, 0x7b, 0xf4, 0xad, 0x51, 0x08, 0xda, 0x3e, 0x51, 0xcd, 0x70, // grub-2.00-22/core.img
|
0x8b, 0x93, 0x7e, 0x5e, 0x8b, 0xae, 0x5a, 0xf8, 0xc8, 0x95, 0x63, 0xc0, 0x0e, 0x9c, 0xaf, 0xc6, 0xcd, 0x7c, 0x2c, 0x80, 0x8a, 0xda, 0x7b, 0xf4, 0xad, 0x51, 0x08, 0xda, 0x3e, 0x51, 0xcd, 0x70, // grub-2.00-22/core.img
|
||||||
|
|
|
||||||
|
|
@ -1765,15 +1765,11 @@ const char* GetFsName(HANDLE hPhysical, LARGE_INTEGER StartingOffset)
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
// 1. Try to detect ISO9660/FAT/exFAT/NTFS/ReFS/SquashFS through the 512 bytes superblock at offset 0
|
// 1. Try to detect ISO9660/FAT/exFAT/NTFS/ReFS through the 512 bytes superblock at offset 0
|
||||||
if (!SetFilePointerEx(hPhysical, StartingOffset, NULL, FILE_BEGIN))
|
if (!SetFilePointerEx(hPhysical, StartingOffset, NULL, FILE_BEGIN))
|
||||||
goto out;
|
goto out;
|
||||||
if (!ReadFile(hPhysical, buf, sector_size, &size, NULL) || size != sector_size)
|
if (!ReadFile(hPhysical, buf, sector_size, &size, NULL) || size != sector_size)
|
||||||
goto out;
|
goto out;
|
||||||
if (memcmp("hsqs", buf, 4) == 0) {
|
|
||||||
ret = "SquashFS";
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (strncmp("CD001", &buf[0x01], 5) == 0) {
|
if (strncmp("CD001", &buf[0x01], 5) == 0) {
|
||||||
ret = "ISO9660";
|
ret = "ISO9660";
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
15
src/format.c
15
src/format.c
|
|
@ -1072,18 +1072,10 @@ BOOL WritePBR(HANDLE hLogicalVolume)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_progress(const int64_t processed_bytes)
|
static void update_progress(const uint64_t processed_bytes)
|
||||||
{
|
{
|
||||||
static uint64_t total_bytes;
|
UpdateProgressWithInfo(OP_FORMAT, MSG_261, processed_bytes, img_report.image_size);
|
||||||
|
uprint_progress(processed_bytes, img_report.image_size);
|
||||||
if (processed_bytes < 0) {
|
|
||||||
total_bytes = -processed_bytes;
|
|
||||||
UpdateProgressWithInfo(OP_FORMAT, MSG_261, 0, total_bytes);
|
|
||||||
uprint_progress(0, total_bytes);
|
|
||||||
} else {
|
|
||||||
UpdateProgressWithInfo(OP_FORMAT, MSG_261, processed_bytes, total_bytes);
|
|
||||||
uprint_progress(processed_bytes, total_bytes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some compressed images use streams that aren't multiple of the sector
|
// Some compressed images use streams that aren't multiple of the sector
|
||||||
|
|
@ -1296,6 +1288,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, BOOL bZeroDrive)
|
||||||
if_assert_fails((uintptr_t)sec_buf% SelectedDrive.SectorSize == 0)
|
if_assert_fails((uintptr_t)sec_buf% SelectedDrive.SectorSize == 0)
|
||||||
goto out;
|
goto out;
|
||||||
sec_buf_pos = 0;
|
sec_buf_pos = 0;
|
||||||
|
update_progress(0);
|
||||||
bled_init(256 * KB, uprintf, NULL, sector_write, update_progress, NULL, &ErrorStatus);
|
bled_init(256 * KB, uprintf, NULL, sector_write, update_progress, NULL, &ErrorStatus);
|
||||||
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
|
|
|
||||||
|
|
@ -1532,6 +1532,7 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* hash)
|
||||||
HASH_CONTEXT hash_ctx = { {0} };
|
HASH_CONTEXT hash_ctx = { {0} };
|
||||||
HANDLE h = INVALID_HANDLE_VALUE;
|
HANDLE h = INVALID_HANDLE_VALUE;
|
||||||
DWORD rs = 0;
|
DWORD rs = 0;
|
||||||
|
uint64_t rb;
|
||||||
uint8_t buf[4096];
|
uint8_t buf[4096];
|
||||||
|
|
||||||
if ((type >= HASH_MAX) || (path == NULL) || (hash == NULL))
|
if ((type >= HASH_MAX) || (path == NULL) || (hash == NULL))
|
||||||
|
|
@ -1545,7 +1546,7 @@ BOOL HashFile(const unsigned type, const char* path, uint8_t* hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_init[type](&hash_ctx);
|
hash_init[type](&hash_ctx);
|
||||||
while(1) {
|
for (rb = 0; ; rb += rs) {
|
||||||
CHECK_FOR_USER_CANCEL;
|
CHECK_FOR_USER_CANCEL;
|
||||||
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
if (!ReadFile(h, buf, sizeof(buf), &rs, NULL)) {
|
||||||
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
ErrorStatus = RUFUS_ERROR(ERROR_READ_FAULT);
|
||||||
|
|
|
||||||
|
|
@ -1391,8 +1391,6 @@ DWORD WINAPI ImageScanThread(LPVOID param)
|
||||||
(img_report.compression_type != BLED_COMPRESSION_NONE && img_report.compression_type < BLED_COMPRESSION_MAX) ?
|
(img_report.compression_type != BLED_COMPRESSION_NONE && img_report.compression_type < BLED_COMPRESSION_MAX) ?
|
||||||
"compressed " : "", img_report.is_vhd ? "VHD" : "disk");
|
"compressed " : "", img_report.is_vhd ? "VHD" : "disk");
|
||||||
selection_default = BT_IMAGE;
|
selection_default = BT_IMAGE;
|
||||||
if (img_report.projected_size > 0)
|
|
||||||
uprintf(" Size: %s (Projected)", SizeToHumanReadable(img_report.projected_size, FALSE, FALSE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (img_report.is_iso) {
|
if (img_report.is_iso) {
|
||||||
|
|
@ -1527,8 +1525,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param)
|
||||||
Notification(MB_OK | MB_ICONERROR, lmprintf(MSG_358), lmprintf(MSG_359));
|
Notification(MB_OK | MB_ICONERROR, lmprintf(MSG_358), lmprintf(MSG_359));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
/* Add 4 KB extra margin for VHD footers and so on */
|
if ((size_check) && (img_report.projected_size > (uint64_t)SelectedDrive.DiskSize)) {
|
||||||
if ((size_check) && (img_report.projected_size > ((uint64_t)SelectedDrive.DiskSize + 4 * KB))) {
|
|
||||||
// This ISO image is too big for the selected target
|
// This ISO image is too big for the selected target
|
||||||
Notification(MB_OK | MB_ICONERROR, lmprintf(MSG_088), lmprintf(MSG_089));
|
Notification(MB_OK | MB_ICONERROR, lmprintf(MSG_088), lmprintf(MSG_089));
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
10
src/rufus.rc
10
src/rufus.rc
|
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 4.15.2396"
|
CAPTION "Rufus 4.15.2391"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
|
@ -409,8 +409,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 4,15,2396,0
|
FILEVERSION 4,15,2391,0
|
||||||
PRODUCTVERSION 4,15,2396,0
|
PRODUCTVERSION 4,15,2391,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
|
@ -428,13 +428,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "4.15.2396"
|
VALUE "FileVersion", "4.15.2391"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2026 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2026 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-4.15.exe"
|
VALUE "OriginalFilename", "rufus-4.15.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "4.15.2396"
|
VALUE "ProductVersion", "4.15.2391"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
||||||
10
src/stdio.c
10
src/stdio.c
|
|
@ -967,15 +967,9 @@ static void print_extracted_file(const char* file_path, uint64_t file_length)
|
||||||
PrintStatus(0, MSG_000, str); // MSG_000 is "%s"
|
PrintStatus(0, MSG_000, str); // MSG_000 is "%s"
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_progress(const int64_t processed_bytes)
|
static void update_progress(const uint64_t processed_bytes)
|
||||||
{
|
{
|
||||||
static uint64_t total_bytes = 0;
|
UpdateProgressWithInfo(OP_EXTRACT_ZIP, MSG_348, processed_bytes, archive_size);
|
||||||
|
|
||||||
if (processed_bytes < 0) {
|
|
||||||
total_bytes = -processed_bytes;
|
|
||||||
UpdateProgressWithInfo(OP_EXTRACT_ZIP, MSG_348, 0, total_bytes);
|
|
||||||
} else
|
|
||||||
UpdateProgressWithInfo(OP_EXTRACT_ZIP, MSG_348, processed_bytes, total_bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract content from a zip archive onto the designated directory or drive
|
// Extract content from a zip archive onto the designated directory or drive
|
||||||
|
|
|
||||||
12
src/stdlg.c
12
src/stdlg.c
|
|
@ -838,17 +838,17 @@ static int GetComboBoxMinWidth(HWND hCtrl, StrArray* array)
|
||||||
return max_width + arrow_width + padding;
|
return max_width + arrow_width + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID ShowSilentOption(HWND hDlg, int index, BOOL show)
|
static VOID ShowSilentOption(HWND hDlg, int s, BOOL show)
|
||||||
{
|
{
|
||||||
int i, dh;
|
int i, dh;
|
||||||
RECT rc1, rc2;
|
RECT rc1, rc2;
|
||||||
|
|
||||||
ShowWindow(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + selection_data[index].options->edition_index - 1), show ? SW_SHOW : SW_HIDE);
|
ShowWindow(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + selection_data[s].options->edition_index - 1), show ? SW_SHOW : SW_HIDE);
|
||||||
ShowWindow(GetDlgItem(hDlg, IDC_SELECTION_EDITION), show ? SW_SHOW : SW_HIDE);
|
ShowWindow(GetDlgItem(hDlg, IDC_SELECTION_EDITION), show ? SW_SHOW : SW_HIDE);
|
||||||
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1), &rc1);
|
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1), &rc1);
|
||||||
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE2), &rc2);
|
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE2), &rc2);
|
||||||
dh = show ? (rc2.top - rc1.top) : (rc1.top - rc2.top);
|
dh = show ? (rc2.top - rc1.top) : (rc1.top - rc2.top);
|
||||||
for (i = selection_data[index].options->edition_index; i < (int)selection_data[index].options->choices.Index; i++)
|
for (i = selection_data[s].options->edition_index; i < (int)selection_data[s].options->choices.Index; i++)
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + i), 0, dh, 0, 0, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + i), 0, dh, 0, 0, 1.0f);
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDOK), 0, dh, 0, 0, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDOK), 0, dh, 0, 0, 1.0f);
|
||||||
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDCANCEL), 0, dh, 0, 0, 1.0f);
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDCANCEL), 0, dh, 0, 0, 1.0f);
|
||||||
|
|
@ -1055,6 +1055,7 @@ static INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam
|
||||||
break;
|
break;
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
BOOL enable = TRUE;
|
BOOL enable = TRUE;
|
||||||
|
BOOL silent_install_checked = FALSE;
|
||||||
WORD command = LOWORD(wParam);
|
WORD command = LOWORD(wParam);
|
||||||
if (command >= IDC_SELECTION_CHOICE1 && command < IDC_SELECTION_CHOICEMAX) {
|
if (command >= IDC_SELECTION_CHOICE1 && command < IDC_SELECTION_CHOICEMAX) {
|
||||||
if (selection_data[s].options->flags & SELECTION_NEEDS_ALL_TO_PROCEED) {
|
if (selection_data[s].options->flags & SELECTION_NEEDS_ALL_TO_PROCEED) {
|
||||||
|
|
@ -1416,11 +1417,12 @@ void DestroyTooltip(HWND hControl)
|
||||||
|
|
||||||
void DestroyAllTooltips(void)
|
void DestroyAllTooltips(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < MAX_TOOLTIPS; i++) {
|
for (i = 0, j = 0; i < MAX_TOOLTIPS; i++) {
|
||||||
if (ttlist[i].hTip == NULL)
|
if (ttlist[i].hTip == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
j++;
|
||||||
DestroyWindow(ttlist[i].hTip);
|
DestroyWindow(ttlist[i].hTip);
|
||||||
safe_free(ttlist[i].wstring);
|
safe_free(ttlist[i].wstring);
|
||||||
ttlist[i].original_proc = NULL;
|
ttlist[i].original_proc = NULL;
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,6 @@ static int8_t IsCompressedBootableImage(const char* path)
|
||||||
ErrorStatus = 0;
|
ErrorStatus = 0;
|
||||||
if (img_report.compression_type < BLED_COMPRESSION_MAX) {
|
if (img_report.compression_type < BLED_COMPRESSION_MAX) {
|
||||||
bled_init(0, uprintf, NULL, NULL, NULL, NULL, &ErrorStatus);
|
bled_init(0, uprintf, NULL, NULL, NULL, NULL, &ErrorStatus);
|
||||||
dc = bled_get_uncompressed_size(path, file_assoc[i].type);
|
|
||||||
if (dc > 0)
|
|
||||||
img_report.projected_size = dc;
|
|
||||||
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
} else if (img_report.compression_type == BLED_COMPRESSION_MAX) {
|
} else if (img_report.compression_type == BLED_COMPRESSION_MAX) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue