diff options
author | Timo Teräs <timo.teras@iki.fi> | 2010-09-14 18:12:57 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2010-09-14 18:12:57 +0300 |
commit | c5cd32de1bea2ea0910a898bed21e68d7cc30c9f (patch) | |
tree | 84ac6562c44900a3332190741b5c54e5cfc0d232 | |
parent | 84354c50f807607700b95debdd3a7ddfde0c09f9 (diff) | |
download | squark-c5cd32de1bea2ea0910a898bed21e68d7cc30c9f.tar.bz2 squark-c5cd32de1bea2ea0910a898bed21e68d7cc30c9f.tar.xz |
authdb: fix memory corruption bugs
properly calculate module of the hash bucket, and when cleaning up
free the correct entry (instead of the next one).
-rw-r--r-- | authdb.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -93,7 +93,7 @@ void authdb_close(struct authdb *adb) for (i = 0; i < ARRAY_SIZE(adb->hash_bucket); i++) { for (c = adb->hash_bucket[i]; c != NULL; c = n) { n = c->next; - authdb_me_free(n); + authdb_me_free(c); } } } @@ -156,7 +156,9 @@ void *authdb_get(struct authdb *adb, sockaddr_any *addr, struct authdb_entry *en e = b.ptr[0]; b.ptr[0] = 0x00; + hash = b.ptr[1] + b.ptr[2] + b.ptr[3]; + hash %= ARRAY_SIZE(adb->hash_bucket); for (me = adb->hash_bucket[hash]; me != NULL; me = me->next) { if (addr_cmp(&baseaddr, &me->baseaddr) == 0) |