[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [leafnode-list] leafnode 2.0b8_ma8rc2 available



Leopold Toetsch wrote:

[ Answering myself ]

> First, there seems to be a serious change in the hashing of message-IDs:

msgid_hash.c in 2.0b8_marc4 is different then the old 19.19 hash.
I verified this by extracting the relevant parts and generating 2 
standalone test programs.

The problem is:

1.9.19:

     i = strlen( name );
<snip>
     do {
          r += (int)(name[i]);
          r += ++i; <<<<<<<<<< i contains strlen of name already
     } while ( name[i] );

2.0

     i = 0;

almost same while loop.


So there are different msgid-hashes, which everybody including me does 
definitliy not want, when upgrading from older versions.

I fixed it now with the appended diffs.
A test with slrn (HEAD / XPAT) worked fine.

The problem is now, what to do with the wrong msgids.

leo




--- msgid_hash.c	Thu Dec 20 05:42:32 2001
+++ /mnt/lt/src/leafnode/msgid_hash.c	Thu Dec 20 16:20:05 2001
@@ -3,18 +3,16 @@
 #include "msgid.h"
 
 unsigned int
-msgid_hash(const char *name)
+msgid_hash(const char *name, int j)
 {
     int i = 0;
     unsigned int r = 0;
-    int stop = 0;
 
     do {
-	if (name[i] == '>')
-	    ++stop;
-	r += (int)((unsigned char)name[i]);
-	r += ++i;
-    } while (!stop && name[i]);
+	r += (int)(name[i]);
+	r += ++j;
+        i++;
+    } while (name[i]);
 
     r = r % 999 + 1;
     return r;


--- miscutil.c	Thu Dec 20 05:42:32 2001
+++ /mnt/lt/src/leafnode/miscutil.c	Thu Dec 20 16:20:46 2001
@@ -396,7 +396,7 @@
     static char *name = NULL;
     static unsigned int namelen = 0;
     unsigned int r;
-    unsigned int i;
+    unsigned int i, j;
     char *p, *q;
 
     if (!msgid || !*msgid)
@@ -414,9 +414,10 @@
 
     p = mastrcpy(name, spooldir);
     p = mastrcpy(p, "/message.id/");
+    j = strlen(name) + 4;
     q = mastrcpy(p + 4, msgid);
     msgid_sanitize(p + 4);
-    r = msgid_hash(p + 4);
+    r = msgid_hash(p + 4, j);
     str_ulong0(p, r, 3);
     p[3] = '/';
     return name;


--- msgid.h	Thu Dec 20 05:42:32 2001
+++ /mnt/lt/src/leafnode/msgid.h	Thu Dec 20 16:20:17 2001
@@ -2,6 +2,6 @@
 #define MSGID_H
 
 void msgid_sanitize(char *m);
-unsigned int msgid_hash(const char *name);
+unsigned int msgid_hash(const char *name, int j);
 
 #endif