[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
This commit is contained in:
Will Thompson 2017-10-12 16:40:54 +01:00 committed by Pete Batard
parent 293440b2e9
commit 88631806da
2 changed files with 14 additions and 7 deletions

View File

@ -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

View File

@ -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"