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