Added sanity checks to the vmware4 and vvfat mode to avoid data corruption.

Some compilers need special options to pack structures correctly.
Added example for gcc 4.7+ on Windows to shortcut script.
This commit is contained in:
Volker Ruppert 2013-11-01 11:34:51 +00:00
parent 635774e1da
commit 57272ac32e
3 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@
CC="gcc"
CXX="g++"
CFLAGS="-O3 -Wall -Wno-format -mno-cygwin"
#CFLAGS="-O3 -Wall -Wno-format -march=pentium -mno-ms-bitfields" # for GCC 4.7+
CXXFLAGS="$CFLAGS"
export CC

View File

@ -53,6 +53,9 @@ vmware4_image_t::vmware4_image_t()
current_offset(INVALID_OFFSET),
is_dirty(0)
{
if (sizeof(_VM4_Header) != 72) {
BX_PANIC(("system error: invalid header structure size"));
}
}
vmware4_image_t::~vmware4_image_t()

View File

@ -343,6 +343,10 @@ infosector_t;
vvfat_image_t::vvfat_image_t(Bit64u size, const char* _redolog_name)
{
if (sizeof(bootsector_t) != 512) {
BX_PANIC(("system error: invalid bootsector structure size"));
}
first_sectors = new Bit8u[0xc000];
memset(&first_sectors[0], 0, 0xc000);