diff --git a/devices/common/ata/atahd.cpp b/devices/common/ata/atahd.cpp index 73cf02f..131c6d8 100644 --- a/devices/common/ata/atahd.cpp +++ b/devices/common/ata/atahd.cpp @@ -63,11 +63,15 @@ int AtaHardDisk::device_postinit() { void AtaHardDisk::insert_image(std::string filename) { if (!this->hdd_img.open(filename)) { - ABORT_F("%s: could not open image file", this->name.c_str()); + ABORT_F("%s: could not open image file \"%s\"", this->name.c_str(), filename.c_str()); } this->img_size = this->hdd_img.size(); - this->total_sectors = this->hdd_img.size() / ATA_HD_SEC_SIZE; + uint64_t sectors = this->hdd_img.size() / ATA_HD_SEC_SIZE; + this->total_sectors = (uint32_t)sectors; + if (sectors != this->total_sectors) { + ABORT_F("%s: image file \"%s\" is too big", this->name.c_str(), filename.c_str()); + } this->calc_chs_params(); }