summaryrefslogtreecommitdiff
path: root/firmware/common/crc32.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-01-09 21:37:07 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2014-01-16 10:17:39 +0100
commit7ab237b025cbb4c25d345604da32e894379c1721 (patch)
tree92d147029519c55d57db4273066d57b960ad7158 /firmware/common/crc32.c
parent7f5dce4116bf4e62e0cd3ef16730157e17625e1c (diff)
downloadrockbox-7ab237b025cbb4c25d345604da32e894379c1721.tar.gz
rockbox-7ab237b025cbb4c25d345604da32e894379c1721.zip
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>
Diffstat (limited to 'firmware/common/crc32.c')
-rw-r--r--firmware/common/crc32.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/firmware/common/crc32.c b/firmware/common/crc32.c
index 1cd0ca0bd5..c8c70e415c 100644
--- a/firmware/common/crc32.c
+++ b/firmware/common/crc32.c
@@ -25,7 +25,7 @@
25 25
26/* Tool function to calculate a CRC32 across some buffer */ 26/* Tool function to calculate a CRC32 across some buffer */
27/* third argument is either 0xFFFFFFFF to start or value from last piece */ 27/* third argument is either 0xFFFFFFFF to start or value from last piece */
28unsigned crc_32(const void *src, unsigned len, unsigned crc32) 28uint32_t crc_32(const void *src, uint32_t len, uint32_t crc32)
29{ 29{
30 const unsigned char *buf = (const unsigned char *)src; 30 const unsigned char *buf = (const unsigned char *)src;
31 31
@@ -39,7 +39,7 @@ unsigned crc_32(const void *src, unsigned len, unsigned crc32)
39 }; 39 };
40 40
41 unsigned char byte; 41 unsigned char byte;
42 unsigned t; 42 uint32_t t;
43 43
44 while (len--) 44 while (len--)
45 { 45 {