Fix out-of-bounds read in OSX disk checking (#2658).
authorCarl Hetherington <cth@carlh.net>
Sun, 19 Nov 2023 20:07:25 +0000 (21:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 19 Nov 2023 20:07:25 +0000 (21:07 +0100)
src/lib/cross_common.cc

index e8c209b21e098f8da981bd5676af55c0c00b65ab..b4d322096a5645f3bf7f7fd5c09d40f94279b3ef 100644 (file)
@@ -172,7 +172,7 @@ osx_disks_to_drives (vector<OSXDisk> disks)
                        continue;
                }
                for (auto& j: disks) {
-                       if (!j.mount_points.empty() && starts_with(j.device, i.device)) {
+                       if (&i != &j && !j.mount_points.empty() && starts_with(j.device, i.device)) {
                                LOG_DISK("Marking %1 as mounted because %2 is", i.device, j.device);
                                std::copy(j.mount_points.begin(), j.mount_points.end(), back_inserter(i.mount_points));
                        }