Skip to content
This repository has been archived by the owner on May 9, 2018. It is now read-only.

Commit

Permalink
Fixing off-by-one error in Curve client-auth public key hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreams committed Aug 9, 2014
1 parent 7c759ae commit ef7a484
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mods/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ int rehash_keybags(struct keybaghash * o) {
struct keybag * curkey = o->data[kiter], *savekey;
while(curkey) {
uint32_t hash = fnv_hash(curkey->key) & newsize;
if(hash == newsize)
hash -= 1;
savekey = curkey->next;
curkey->next = newdata[hash];
newdata[hash] = curkey;
Expand Down Expand Up @@ -425,6 +427,8 @@ int read_keyfile(const char * path, struct keybaghash * o) {
}

uint32_t hashval = fnv_hash(nk->key) & o->buckets;
if(hashval == o->buckets)
hashval -= 1;

nk->next = o->data[hashval];
o->data[hashval] = nk;
Expand Down Expand Up @@ -540,6 +544,8 @@ void * zap_handler(void* zapsock) {

uint32_t hashval = fnv_hash(creds);
hashval &= bag.buckets;
if(hashval == bag.buckets)
hashval -= 1;

struct keybag * search = bag.data[hashval];

Expand Down

0 comments on commit ef7a484

Please sign in to comment.