From eedeaea75ff103b2df0f306ed972244abaf46b58 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 22 Jun 2026 18:15:06 +0100 Subject: [PATCH] [misc] fix multiple small issues * Use the actual Bled latest to fix a potential crash in ZSTD decompression as well as wrong disk size computation. * Fix wrong parenthesis placement for projected vs actual disk size check. * Update GitHub Actions to latest. Closes #3000. --- .github/workflows/codeql.yml | 2 +- .github/workflows/coverity.yml | 2 +- .github/workflows/mingw.yml | 2 +- .github/workflows/setup.yml | 2 +- .github/workflows/vs2026.yml | 2 +- src/bled/bled_size.c | 29 ++++++++++++++--------------- src/bled/decompress_unzstd.c | 4 ++-- src/rufus.c | 2 +- src/rufus.rc | 10 +++++----- 9 files changed, 27 insertions(+), 28 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 132541b4..1d45057d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -41,7 +41,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Initialize CodeQL uses: github/codeql-action/init@v4 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index fa324ed3..bbee991e 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 submodules: recursive diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index 8e1df007..d59adfd5 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -54,7 +54,7 @@ jobs: upx - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 submodules: recursive diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 0ff81dc5..c0fc073a 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v3 diff --git a/.github/workflows/vs2026.yml b/.github/workflows/vs2026.yml index 2c368afb..371f4d5a 100644 --- a/.github/workflows/vs2026.yml +++ b/.github/workflows/vs2026.yml @@ -40,7 +40,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 submodules: recursive diff --git a/src/bled/bled_size.c b/src/bled/bled_size.c index 403c3e2b..4c9dda1a 100644 --- a/src/bled/bled_size.c +++ b/src/bled/bled_size.c @@ -727,25 +727,24 @@ int64_t get_uncompressed_size_from_disk_image(int fd, int type) size = DECOMP_SIZE_UNKNOWN; goto out; } - if (buf[0x1c2] == 0xee) { - /* Protective EFI MBR => look for the primary GPT, which'll also give us the sector size */ - if (memcmp("EFI PART", &buf[0x200], 8) == 0) { - /* The address of the backup GPT is assumed to be the last LBA for the disk */ - size = get_le64(&buf[0x220]) * 512; - goto out; - } - if (memcmp("EFI PART", &buf[0x1000], 8) == 0) { - size = get_le64(&buf[0x1020]) * 8192; - goto out; - } - } - if (buf[0x1be] == 0x80) { + 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 * 512; /* assume 512-byte sectors for anything MBR based */ - if (size < 8192) + size = (max_lba + 1) * 512; /* assume 512-byte sectors for anything MBR based */ + if (size < 4096) size = DECOMP_SIZE_UNKNOWN; } diff --git a/src/bled/decompress_unzstd.c b/src/bled/decompress_unzstd.c index 85eaa474..4c6cdee7 100644 --- a/src/bled/decompress_unzstd.c +++ b/src/bled/decompress_unzstd.c @@ -119,8 +119,8 @@ unpack_zstd_stream_inner(transformer_state_t *xstate, IF_DESKTOP(long long) int FAST_FUNC unpack_zstd_stream(transformer_state_t *xstate) { - const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), 1024), - out_allocsize = roundupsize(ZSTD_DStreamOutSize(), 1024); + const size_t in_allocsize = roundupsize(ZSTD_DStreamInSize(), SECTOR_ALIGNMENT), + out_allocsize = roundupsize(ZSTD_DStreamOutSize(), SECTOR_ALIGNMENT); IF_DESKTOP(long long) int result; void *out_buff; diff --git a/src/rufus.c b/src/rufus.c index 4a92d6a0..83803ce3 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -1528,7 +1528,7 @@ static DWORD WINAPI BootCheckThread(LPVOID param) goto out; } /* Add 4 KB extra margin for VHD footers and so on */ - if ((size_check) && (img_report.projected_size > (uint64_t)SelectedDrive.DiskSize) + 4 * KB) { + if ((size_check) && (img_report.projected_size > ((uint64_t)SelectedDrive.DiskSize + 4 * KB))) { // This ISO image is too big for the selected target Notification(MB_OK | MB_ICONERROR, lmprintf(MSG_088), lmprintf(MSG_089)); goto out; diff --git a/src/rufus.rc b/src/rufus.rc index a4631124..b15b9e7a 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 4.15.2394" +CAPTION "Rufus 4.15.2395" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -409,8 +409,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,15,2394,0 - PRODUCTVERSION 4,15,2394,0 + FILEVERSION 4,15,2395,0 + PRODUCTVERSION 4,15,2395,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -428,13 +428,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.15.2394" + VALUE "FileVersion", "4.15.2395" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2026 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.15.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.15.2394" + VALUE "ProductVersion", "4.15.2395" END END BLOCK "VarFileInfo"