diff options
author | Linus Nordberg <linus@nordberg.se> | 2015-01-16 16:31:02 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2015-01-16 16:31:02 +0100 |
commit | 0a1fa90d723d085bc869bc423619e1a8ee421fd0 (patch) | |
tree | b3594021fb03693cd8e04c45d4826323ed1fcf22 | |
parent | c2c7de6bf42a8598e9a482a452c1f3edb34d2c94 (diff) |
Fix use-after-free in hash_extract().
Patch by Stephen Röttger.
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | hash.c | 4 |
2 files changed, 4 insertions, 1 deletions
@@ -22,4 +22,5 @@ Ralf Paffrath Simon Leinen Simon Lundström Stefan Winter +Stephen Röttger Stig Venaas @@ -87,6 +87,7 @@ void *hash_read(struct hash *h, void *key, uint32_t keylen) { void *hash_extract(struct hash *h, void *key, uint32_t keylen) { struct list_node *ln; struct hash_entry *e; + void *data; if (!h) return 0; @@ -96,9 +97,10 @@ void *hash_extract(struct hash *h, void *key, uint32_t keylen) { if (e->keylen == keylen && !memcmp(e->key, key, keylen)) { free(e->key); list_removedata(h->hashlist, e); + data = e->data; free(e); pthread_mutex_unlock(&h->mutex); - return e->data; + return data; } } pthread_mutex_unlock(&h->mutex); |