From cdde324d77b99ef1d2eefe5c5127cdbbe2617778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 10 Apr 2008 11:43:45 +0000 Subject: [PATCH] * Looks like r24456 was a bit premature: with string attributes, it makes sense to ignore a trailing null byte, which the code now didn't do anymore. * This caused bug #2054. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24888 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 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 d9596591a7..f33c375ae3 100644 --- a/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BPlusTree.cpp @@ -2311,8 +2311,16 @@ compareKeys(type_code type, const void *key1, int keyLength1, case B_STRING_TYPE: { int result = memcmp(key1, key2, min_c(keyLength1, keyLength2)); - if (result == 0) + if (result == 0) { + // ignore trailing null bytes + if ((keyLength1 == keyLength2 + 1 + && ((uint8 *)key1)[keyLength2] == '\0') + || (keyLength2 == keyLength1 + 1 + && ((uint8 *)key2)[keyLength1] == '\0')) + return 0; + result = keyLength1 - keyLength2; + } return result; }