* HTree::_PrepareBlocksForHash() now uses arithmetic sum instead of bitwise, this should help to fix #7084.
* cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40202 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -89,10 +89,7 @@ HTree::PrepareForHash()
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
CachedBlock cached(fDirectory->GetVolume());
|
CachedBlock cached(fDirectory->GetVolume());
|
||||||
const uint8* block = cached.SetTo(blockNum);
|
HTreeRoot* root = (HTreeRoot*)cached.SetTo(blockNum);
|
||||||
|
|
||||||
HTreeRoot* root = (HTreeRoot*)block;
|
|
||||||
|
|
||||||
if (root == NULL)
|
if (root == NULL)
|
||||||
return B_IO_ERROR;
|
return B_IO_ERROR;
|
||||||
if (!root->IsValid())
|
if (!root->IsValid())
|
||||||
@@ -120,10 +117,7 @@ HTree::Lookup(const char* name, DirectoryIterator** iterator)
|
|||||||
return _FallbackToLinearIteration(iterator);
|
return _FallbackToLinearIteration(iterator);
|
||||||
|
|
||||||
CachedBlock cached(fDirectory->GetVolume());
|
CachedBlock cached(fDirectory->GetVolume());
|
||||||
const uint8* block = cached.SetTo(blockNum);
|
HTreeRoot* root = (HTreeRoot*)cached.SetTo(blockNum);
|
||||||
|
|
||||||
HTreeRoot* root = (HTreeRoot*)block;
|
|
||||||
|
|
||||||
if (root == NULL || !root->IsValid())
|
if (root == NULL || !root->IsValid())
|
||||||
return _FallbackToLinearIteration(iterator);
|
return _FallbackToLinearIteration(iterator);
|
||||||
|
|
||||||
@@ -248,7 +242,6 @@ void
|
|||||||
HTree::_HalfMD4Transform(uint32 buffer[4], uint32 blocks[8])
|
HTree::_HalfMD4Transform(uint32 buffer[4], uint32 blocks[8])
|
||||||
{
|
{
|
||||||
uint32 a, b, c, d;
|
uint32 a, b, c, d;
|
||||||
|
|
||||||
a = buffer[0];
|
a = buffer[0];
|
||||||
b = buffer[1];
|
b = buffer[1];
|
||||||
c = buffer[2];
|
c = buffer[2];
|
||||||
@@ -311,7 +304,7 @@ HTree::_HashHalfMD4(const char* name, uint8 _length)
|
|||||||
{
|
{
|
||||||
TRACE("HTree::_HashHalfMD4()\n");
|
TRACE("HTree::_HashHalfMD4()\n");
|
||||||
uint32 buffer[4];
|
uint32 buffer[4];
|
||||||
int32 length = (uint32)_length;
|
int32 length = _length;
|
||||||
|
|
||||||
buffer[0] = fHashSeed[0];
|
buffer[0] = fHashSeed[0];
|
||||||
buffer[1] = fHashSeed[1];
|
buffer[1] = fHashSeed[1];
|
||||||
@@ -387,9 +380,9 @@ void
|
|||||||
HTree::_PrepareBlocksForHash(const char* string, uint32 length, uint32* blocks,
|
HTree::_PrepareBlocksForHash(const char* string, uint32 length, uint32* blocks,
|
||||||
uint32 numBlocks)
|
uint32 numBlocks)
|
||||||
{
|
{
|
||||||
uint32 padding = (uint32)length;
|
uint32 padding = length;
|
||||||
padding = (padding << 8) | padding;
|
padding |= padding << 8;
|
||||||
padding = (padding << 16) | padding;
|
padding |= padding << 16;
|
||||||
|
|
||||||
uint32 numBytes = numBlocks * 4;
|
uint32 numBytes = numBlocks * 4;
|
||||||
if (length > numBytes)
|
if (length > numBytes)
|
||||||
@@ -398,10 +391,10 @@ HTree::_PrepareBlocksForHash(const char* string, uint32 length, uint32* blocks,
|
|||||||
uint32 completeIterations = length / 4;
|
uint32 completeIterations = length / 4;
|
||||||
|
|
||||||
for (uint32 i = 0; i < completeIterations; ++i) {
|
for (uint32 i = 0; i < completeIterations; ++i) {
|
||||||
uint32 value = (padding << 8) | *(string++);
|
uint32 value = (padding << 8) + *(string++);
|
||||||
value = (value << 8) | *(string++);
|
value = (value << 8) + *(string++);
|
||||||
value = (value << 8) | *(string++);
|
value = (value << 8) + *(string++);
|
||||||
value = (value << 8) | *(string++);
|
value = (value << 8) + *(string++);
|
||||||
blocks[i] = value;
|
blocks[i] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,3 +420,4 @@ HTree::_FallbackToLinearIteration(DirectoryIterator** iterator)
|
|||||||
|
|
||||||
return *iterator == NULL ? B_NO_MEMORY : B_OK;
|
return *iterator == NULL ? B_NO_MEMORY : B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user