]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
dirhash.c (ext2fs_dirhash): Fix bug which caused MD4
authorTheodore Ts'o <tytso@mit.edu>
Tue, 23 Jul 2002 17:11:53 +0000 (13:11 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 23 Jul 2002 17:11:53 +0000 (13:11 -0400)
calculations for names > 32 characters to be completely
bogus.  Changed MD4 calculation to match what is currently
being used in the CVS gkernel tree.

lib/ext2fs/ChangeLog
lib/ext2fs/dirhash.c

index 4bbbca229b1d8dd1ab45ed24850f8f73e3e5e62f..c946de5db7ceed8de96d20a3f81c2f27071692d1 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-23  Theodore Ts'o  <tytso@mit.edu>
+
+       * 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.
+
 2002-07-19  Theodore Ts'o  <tytso@mit.edu>
 
        * ext2_fs.h: Add s_hash_seed and s_def_hash_version to the
index 1d21fe5edc9f86adcc3f890a0a1d7eb9c22b9c47..d3e0e75a4c30e03f42d8ccc969401e0cbc743499 100644 (file)
@@ -75,7 +75,7 @@ static __u32 halfMD4Transform (__u32 buf[4], __u32 const in[])
        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 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
 {
        __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 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len,
                        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;