d8f8be
From 28ac93e737ae4e2055ff23f2ea6021b1127b40a2 Mon Sep 17 00:00:00 2001
d8f8be
From: Rod Smith <rodsmith@rodsbooks.com>
d8f8be
Date: Wed, 13 Jan 2021 10:29:24 -0500
d8f8be
Subject: [PATCH 2/2] Fix bug that could cause crash if a badly-formatted MBR
d8f8be
 disk was read.
d8f8be
d8f8be
---
d8f8be
 basicmbr.cc | 3 ++-
d8f8be
 1 file changed, 2 insertions(+), 1 deletion(-)
d8f8be
d8f8be
diff --git a/basicmbr.cc b/basicmbr.cc
d8f8be
index 8fbffd1..2da56db 100644
d8f8be
--- a/basicmbr.cc
d8f8be
+++ b/basicmbr.cc
d8f8be
@@ -258,7 +258,8 @@ int BasicMBRData::ReadLogicalParts(uint64_t extendedStart, int partNum) {
d8f8be
          if (EbrLocations[i] == offset) { // already read this one; infinite logical partition loop!
d8f8be
             cerr << "Logical partition infinite loop detected! This is being corrected.\n";
d8f8be
             allOK = -1;
d8f8be
-            partNum -= 1;
d8f8be
+            if (partNum > 0) //don't go negative
d8f8be
+               partNum -= 1;
d8f8be
          } // if
d8f8be
       } // for
d8f8be
       EbrLocations[partNum] = offset;
d8f8be
-- 
d8f8be
2.35.1
d8f8be