lib: don't overrun buffer in capn_write_mem_packed
Missing braces end up scaling the offset by * 4 ... which is actually a stack/heap overflow.
This commit is contained in:
parent
0b128565c0
commit
33ae16bba8
1 changed files with 1 additions and 1 deletions
|
|
@ -232,7 +232,7 @@ static int capn_write_mem_packed(struct capn *c, uint8_t *p, size_t sz)
|
||||||
|
|
||||||
root = capn_root(c);
|
root = capn_root(c);
|
||||||
header_calc(c, &headerlen, &headersz);
|
header_calc(c, &headerlen, &headersz);
|
||||||
header = (uint32_t*) p + headersz + 2; /* must reserve two bytes for worst case expansion */
|
header = (uint32_t*) (p + headersz + 2); /* must reserve two bytes for worst case expansion */
|
||||||
|
|
||||||
if (sz < headersz*2 + 2) /* We must have space for temporary writing of header to deflate */
|
if (sz < headersz*2 + 2) /* We must have space for temporary writing of header to deflate */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue