Skip to content

Commit

Permalink
Make sure when detecting partition type that we do not overread over …
Browse files Browse the repository at this point in the history
…a struct and cause crashes
  • Loading branch information
joncampbell123 committed Sep 9, 2023
1 parent fa8295c commit 2051bf1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ints/bios_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3572,6 +3572,9 @@ bool PartitionLoadIPL1(std::vector<_PC98RawPartition> &parts,imageDisk *loadedDi
std::string PartitionIdentifyType(imageDisk *loadedDisk) {
struct partTable mbrData;

if (loadedDisk->getSectSize() > sizeof(mbrData))
return std::string(); /* That would cause a buffer overrun */

if (loadedDisk->Read_Sector(0,0,1,&mbrData) != 0)
return std::string();

Expand Down

0 comments on commit 2051bf1

Please sign in to comment.