From 33d9fb8663e384b7ad8edb015eac2b2ee88c2d3b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 20 Oct 2014 00:13:03 +0200 Subject: [PATCH] BFS: Fix check of key compare in BPlusTree::_ValidateChildren(). In ba320218245aeb11cb74c37ecf7132d0b9903957 the key comparison was fixed to use a compatible version. Since then the check can actually return results other than -1. The check done on the result was too strict however. The child nodes may never contain keys that are larger than the keys they are reached by. But the last key of a child node may be equal to the one in the parent. This change fixes the check to take this special case into account. Fixes #11026 and #11289. The issue was unproblematic in so far that it was only hit during a filesystem check and, since BPlusTree does not yet attempt to correct corrupted trees, did not result in any actual actions. --- src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp index bb281d47fc..1688591bd9 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp @@ -2367,7 +2367,7 @@ BPlusTree::_ValidateChildren(TreeCheck& check, uint32 level, off_t offset, if (largestKey != NULL) { int result = _CompareKeys(key, keyLength, largestKey, largestKeyLength); - if (result >= 0) { + if (result > 0 || (result == 0 && i != count - 1)) { dprintf("inode %" B_PRIdOFF ": node %" B_PRIdOFF " key %" B_PRIu32 " larger than it should!\n", fStream->ID(), offset, i);