[iso] improve handling of image size

* Don't use the projected size where the actual image size should be used
* Also fix an issue with the projected size computation
This commit is contained in:
Pete Batard 2017-05-01 16:22:34 +01:00
parent 0c76dbf075
commit 30137de7cb
7 changed files with 20 additions and 18 deletions

View file

@ -293,19 +293,19 @@ BOOL IsBootableImage(const char* path)
uprintf(" Could not get image size: %s", WindowsErrorString());
goto out;
}
img_report.projected_size = (uint64_t)liImageSize.QuadPart;
img_report.image_size = (uint64_t)liImageSize.QuadPart;
size = sizeof(vhd_footer);
if ((img_report.compression_type == BLED_COMPRESSION_NONE) && (img_report.projected_size >= (512 + size))) {
if ((img_report.compression_type == BLED_COMPRESSION_NONE) && (img_report.image_size >= (512 + size))) {
footer = (vhd_footer*)malloc(size);
ptr.QuadPart = img_report.projected_size - size;
ptr.QuadPart = img_report.image_size - size;
if ( (footer == NULL) || (!SetFilePointerEx(handle, ptr, NULL, FILE_BEGIN)) ||
(!ReadFile(handle, footer, size, &size, NULL)) || (size != sizeof(vhd_footer)) ) {
uprintf(" Could not read VHD footer");
goto out;
}
if (memcmp(footer->cookie, conectix_str, sizeof(footer->cookie)) == 0) {
img_report.projected_size -= sizeof(vhd_footer);
img_report.image_size -= sizeof(vhd_footer);
if ( (bswap_uint32(footer->file_format_version) != VHD_FOOTER_FILE_FORMAT_V1_0)
|| (bswap_uint32(footer->disk_type) != VHD_FOOTER_TYPE_FIXED_HARD_DISK)) {
uprintf(" Unsupported type of VHD image");