Name: Anonymous 2014-05-25 20:36
unsigned long hash(unsigned char *str)
{
unsigned int hash = 0;
int c;
while (c = *str++)
{
hash += c;
}
return hash;
}
Spent hours designing it. It is safer than md5!
unsigned long hash(unsigned char *str)
{
unsigned int hash = 0;
int c;
while (c = *str++)
{
hash += c;
}
return hash;
}
foo = malloc(1);
if(foo) {
*foo = 0;
hash(foo); // bam trap representation, UB invoked inside hash()
free(foo);
}