dirhash.c (ext2fs_dirhash): Fix bug which caused MD4
calculations for names > 32 characters to be completely
bogus. Changed MD4 calculation to match what is currently
being used in the CVS gkernel tree.
diff --git a/lib/ext2fs/dirhash.c b/lib/ext2fs/dirhash.c
index 1d21fe5..d3e0e75 100644
--- a/lib/ext2fs/dirhash.c
+++ b/lib/ext2fs/dirhash.c
@@ -75,7 +75,7 @@
buf[2] += c;
buf[3] += d;
- return (buf[1] << 1); /* "most hashed" word */
+ return ((buf[1] + b) & ~1); /* "most hashed" word */
/* Alternative: return sum of all words? */
}
@@ -121,7 +121,7 @@
{
__u32 hash;
__u32 minor_hash = 0;
- char *p;
+ const char *p;
int i;
/* Check to see if the seed is all zero's */
@@ -144,10 +144,11 @@
buf[2] = 0x98badcfe;
buf[3] = 0x10325476;
} else
- memcpy(buf, in, sizeof(buf));
+ memcpy(buf, seed, sizeof(buf));
+ p = name;
while (len) {
if (len < 32) {
- memcpy(in, name, len);
+ memcpy(in, p, len);
memset(in+len, 0, 32-len);
hash = halfMD4Transform(buf, (__u32 *) in);
break;