[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[leafnode-list] Whoah. Bugs galore in hashing.
My eyes still ache after looking in
*miscutil.c*
/* no good but this server isn't going to be scalable so shut up */
const char *lookup(const char *msgid)
{
static char *name = NULL;
unsigned int r;
/* ... */
i = strlen(name);
strcat(name, msgid);
r = 0;
do {
if (name[i] == '/')
name[i] = '@';
else if (name[i] == '>')
name[i + 1] = '\0';
r += (int) (name[i]);
r += ++i;
} while (name[i]);
i = strlen(spooldir) + 14; /* to the last digit */
r = (r % 999) + 1;
..
}
Ouch.
a) name is char[], if that's signed or unsigned is implementation-dependent
b) r is unsigned int
c) name is cast to (signed) int.
d) the hashing function is embedded. Wrong. Belongs into a separate function.
Going to fix for 2.0b8_ma3.
--
Matthias Andree
--
leafnode-list@xxxxxxxxxxxxxxxxxxxxxxxxxxxx -- mailing list for leafnode
To unsubscribe, send mail with "unsubscribe" in the subject to the list