From 7ab237b025cbb4c25d345604da32e894379c1721 Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Thu, 9 Jan 2014 21:37:07 +0100 Subject: 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 --- firmware/thread.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'firmware/thread.c') diff --git a/firmware/thread.c b/firmware/thread.c index ce9252ccc6..b687144f4f 100644 --- a/firmware/thread.c +++ b/firmware/thread.c @@ -39,6 +39,7 @@ #ifdef RB_PROFILE #include #endif +#include "core_alloc.h" #include "gcc_extensions.h" /**************************************************************************** @@ -1161,6 +1162,11 @@ void switch_thread(void) * to this call. */ store_context(&thread->context); +#ifdef DEBUG + /* Check core_ctx buflib integrity */ + core_check_valid(); +#endif + /* Check if the current thread stack is overflown */ if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0) thread_stkov(thread); -- cgit v1.2.3