Buflib add range checks blocks and crc_slot raise panic if out of range
Change-Id: I81df5c145a8cb003827a5423f484f70333e2472e
This commit is contained in:
parent
929ea73cd6
commit
976831e667
1 changed files with 7 additions and 0 deletions
|
@ -248,9 +248,16 @@ static bool
|
|||
move_block(struct buflib_context* ctx, union buflib_data* block, int shift)
|
||||
{
|
||||
char* new_start;
|
||||
|
||||
if (block < ctx->buf_start || block > ctx->alloc_end)
|
||||
buflib_panic(ctx, "buflib data corrupted %p", block);
|
||||
|
||||
union buflib_data *new_block, *tmp = block[1].handle, *crc_slot;
|
||||
struct buflib_callbacks *ops = block[2].ops;
|
||||
crc_slot = (union buflib_data*)tmp->alloc - 1;
|
||||
if (crc_slot < ctx->buf_start || crc_slot > ctx->alloc_end)
|
||||
buflib_panic(ctx, "buflib metadata corrupted %p", crc_slot);
|
||||
|
||||
const int metadata_size = (crc_slot - block)*sizeof(union buflib_data);
|
||||
uint32_t crc = crc_32((void *)block, metadata_size, 0xffffffff);
|
||||
|
||||
|
|
Loading…
Reference in a new issue