summaryrefslogtreecommitdiff
path: root/firmware/include
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-03-30 20:55:14 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-09-19 15:09:51 -0400
commit8f896b14d32cb338bb18489f3503eedd189c2dc4 (patch)
tree6782d64b7660a06bcb87d0c7c13edad13ce709e4 /firmware/include
parent6e9b1b344b7f7b04a2ae4ace0a1d191f63d03396 (diff)
downloadrockbox-8f896b14d32cb338bb18489f3503eedd189c2dc4.tar.gz
rockbox-8f896b14d32cb338bb18489f3503eedd189c2dc4.zip
buflib: remove the 'name' member from union buflib_data
Using a length 1 char array to point to the name buffer triggers a -Warray-bounds warning from GCC when fortified strcpy is used. This type of construct isn't safe in general -- if the compiler makes assumptions based on the array bound it can create subtle bugs when accessing the array out of bounds. Instead, add a function get_block_name() which returns a pointer to the name field by casting. This suppresses the warning and it should be a bit more portable. Change-Id: I25d4f46f799022ad0ec23bef0218f7595cc741ea
Diffstat (limited to 'firmware/include')
-rw-r--r--firmware/include/buflib.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h
index a4796fbf33..45446c3b86 100644
--- a/firmware/include/buflib.h
+++ b/firmware/include/buflib.h
@@ -38,7 +38,6 @@ union buflib_data
38 intptr_t val; /* length of the block in n*sizeof(union buflib_data). 38 intptr_t val; /* length of the block in n*sizeof(union buflib_data).
39 Includes buflib metadata overhead. A negative value 39 Includes buflib metadata overhead. A negative value
40 indicates block is unallocated */ 40 indicates block is unallocated */
41 char name[1]; /* name, actually a variable sized string */
42 struct buflib_callbacks* ops; /* callback functions for move and shrink. Can be NULL */ 41 struct buflib_callbacks* ops; /* callback functions for move and shrink. Can be NULL */
43 char* alloc; /* start of allocated memory area */ 42 char* alloc; /* start of allocated memory area */
44 union buflib_data *handle; /* pointer to entry in the handle table. 43 union buflib_data *handle; /* pointer to entry in the handle table.