Blob Blame History Raw
From 28ac93e737ae4e2055ff23f2ea6021b1127b40a2 Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
Date: Wed, 13 Jan 2021 10:29:24 -0500
Subject: [PATCH 2/2] Fix bug that could cause crash if a badly-formatted MBR
 disk was read.

---
 basicmbr.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/basicmbr.cc b/basicmbr.cc
index 8fbffd1..2da56db 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -258,7 +258,8 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
          if (EbrLocations[i] == offset) { // already read this one; infinite logical partition loop!
             cerr << "Logical partition infinite loop detected! This is being corrected.\n";
             allOK = -1;
-            partNum -= 1;
+            if (partNum > 0) //don't go negative
+               partNum -= 1;
          } // if
       } // for
       EbrLocations[partNum] = offset;
-- 
2.35.1