From 5d219195bb8b0ed3db7af053142a0f35541870f3 Mon Sep 17 00:00:00 2001 From: ksherlock Date: Sat, 2 Apr 2011 18:14:27 +0000 Subject: [PATCH] Support for 2MG w/o 0 filesize field (leadlight) git-svn-id: https://profuse.googlecode.com/svn/branches/v2@397 aa027e90-d47c-11dd-86d7-074df07e0730 --- Device/UniversalDiskImage.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Device/UniversalDiskImage.cpp b/Device/UniversalDiskImage.cpp index 08f7c4d..23cdacd 100644 --- a/Device/UniversalDiskImage.cpp +++ b/Device/UniversalDiskImage.cpp @@ -107,6 +107,7 @@ bool UniversalDiskImage::Validate(MappedFile *file, const std::nothrow_t &) unsigned blocks = 0; unsigned offset = 0; + unsigned fileSize = 0; if (size < 64) return false; @@ -121,8 +122,11 @@ bool UniversalDiskImage::Validate(MappedFile *file, const std::nothrow_t &) offset = Read32(data, 0x18); // file size == blocks * 512 - if (Read32(data, 0x1c) != blocks * 512) return false; - + // file size blank in some cases. + //if (Read32(data, 0x1c) != blocks * 512) return false; + fileSize = Read32(data, 0x1c); + if (fileSize != 0 && fileSize != blocks * 512) return false; + if (offset + blocks * 512 > size) return false; return true;