Commit ba8badd6 authored by Giovanni Bajo's avatar Giovanni Bajo Committed by Simon Kelley

Fix bug in keydata_alloc()

parent 0decc869
......@@ -1333,6 +1333,8 @@ struct keydata *keydata_alloc(char *data, size_t len)
{
struct keydata *block, *ret = NULL;
struct keydata **prev = &ret;
size_t blen;
while (len > 0)
{
if (keyblock_free)
......@@ -1350,9 +1352,10 @@ struct keydata *keydata_alloc(char *data, size_t len)
return NULL;
}
memcpy(block->key, data, len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len);
data += KEYBLOCK_LEN;
len -= KEYBLOCK_LEN;
blen = len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len;
memcpy(block->key, data, blen);
data += blen;
len -= blen;
*prev = block;
prev = &block->next;
block->next = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment