From 88631806da52d883f30c7feb656bdfc9afcc1235 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 12 Oct 2017 16:40:54 +0100 Subject: [PATCH] [cmp] propagate decompression errors from bled * If, for example, you have a truncated gz-compressed file and try to write it to disk, bled_uncompress_with_handles() will return an error. Previously, this was not reported back to the user. * Closes #1040 --- src/format.c | 11 +++++++++-- src/rufus.rc | 10 +++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/format.c b/src/format.c index 5d1e9353..d9b07d55 100644 --- a/src/format.c +++ b/src/format.c @@ -1531,6 +1531,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) LARGE_INTEGER li; DWORD rSize, wSize, BufSize; uint64_t wb, target_size = hSourceImage?img_report.image_size:SelectedDrive.DiskSize; + int64_t bled_ret; uint8_t *buffer = NULL; int i; @@ -1541,10 +1542,16 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) LastRefresh = 0; if (img_report.compression_type != BLED_COMPRESSION_NONE) { - uprintf("Writing Compressed Image..."); + uprintf("Writing compressed image..."); bled_init(_uprintf, update_progress, &FormatStatus); - bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type); + bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type); bled_exit(); + if ((bled_ret < 0) && (SCODE_CODE(FormatStatus) != ERROR_CANCELLED)) { + // Unfortunately, different compression backends return different negative error codes + uprintf("Could not write compressed image: %" PRIi64, bled_ret); + FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT; + goto out; + } } else { uprintf(hSourceImage?"Writing Image...":"Zeroing drive..."); // Our buffer size must be a multiple of the sector size and *ALIGNED* to the sector size diff --git a/src/rufus.rc b/src/rufus.rc index 397f1ba4..dd7cee17 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.18.1204" +CAPTION "Rufus 2.18.1205" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -366,8 +366,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,18,1204,0 - PRODUCTVERSION 2,18,1204,0 + FILEVERSION 2,18,1205,0 + PRODUCTVERSION 2,18,1205,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -384,13 +384,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.18.1204" + VALUE "FileVersion", "2.18.1205" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.18.1204" + VALUE "ProductVersion", "2.18.1205" END END BLOCK "VarFileInfo"