mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
buflib: Add crc field protecting buflib cookie integrity
This should catch the case of buffer misuse which results in corrupted cookie of next allocation. The check is performed on move_block() so it may be a bit late. There is buflib_check_valid() provided which checks the integrity of all cookies for given context. On DEBUG build with --sdl-thread this check is carried out for core_ctx on every context switch to catch problems earlier. Change-Id: I999d4576084592394e3dbd3bdf0f32935ff5f601 Reviewed-on: http://gerrit.rockbox.org/711 Reviewed-by: Thomas Martitz <kugel@rockbox.org>
This commit is contained in:
parent
7f5dce4116
commit
7ab237b025
9 changed files with 95 additions and 13 deletions
|
@ -40,6 +40,7 @@ union buflib_data
|
|||
struct buflib_callbacks* ops;
|
||||
char* alloc;
|
||||
union buflib_data *handle;
|
||||
uint32_t crc;
|
||||
};
|
||||
|
||||
struct buflib_context
|
||||
|
@ -346,4 +347,9 @@ int buflib_get_num_blocks(struct buflib_context *ctx);
|
|||
*/
|
||||
void buflib_print_block_at(struct buflib_context *ctx, int block_num,
|
||||
char* buf, size_t bufsize);
|
||||
|
||||
/**
|
||||
* Check integrity of given buflib context
|
||||
*/
|
||||
void buflib_check_valid(struct buflib_context *ctx);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue