Commit 36c52c26 authored by Rusty Russell's avatar Rusty Russell

tal/talloc: fix overflow on 64 bit systems

Arguably a bug in talloc_realloc_array, which uses an unsigned for 
size, resulting in silent truncation and a memcpy into a too-small
buffer.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 7207c782
......@@ -141,6 +141,13 @@ bool tal_talloc_resize_(tal_t **ctxp, size_t size, size_t count)
*ctxp = newp;
return true;
}
/* count is unsigned, not size_t, so check for overflow here! */
if ((unsigned)count != count) {
call_error("Resize overflos");
return false;
}
newp = _talloc_realloc_array(NULL, *ctxp, size, count, NULL);
if (!newp) {
call_error("Resize failure");
......
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