mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-01 00:28:18 +00:00
btstack_posix_tlv: use max value size of 2048, assert if size is larger in store
This commit is contained in:
parent
0d37aff3fe
commit
c78b4f699d
@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
- *btstack_run_loop_execute_on_main_thread*: schedule code execution on main thread from other thread
|
||||
- *btstack_run_loop_trigger_exit*: trigger run loop exit
|
||||
- POSIX / Windows / Raspi / Qt: use updated ctrl-c handling
|
||||
- POSIX TLV: use max value size of 2048, assert if size is larger in store
|
||||
|
||||
|
||||
## Release v1.4.1
|
||||
|
@ -54,6 +54,9 @@
|
||||
// - Value: Len in bytes
|
||||
|
||||
#define BTSTACK_TLV_HEADER_LEN 8
|
||||
|
||||
#define MAX_TLV_VALUE_SIZE 2048
|
||||
|
||||
static const char * btstack_tlv_header_magic = "BTstack";
|
||||
|
||||
#define DUMMY_SIZE 4
|
||||
@ -141,6 +144,9 @@ static int btstack_tlv_posix_get_tag(void * context, uint32_t tag, uint8_t * buf
|
||||
static int btstack_tlv_posix_store_tag(void * context, uint32_t tag, const uint8_t * data, uint32_t data_size){
|
||||
btstack_tlv_posix_t * self = (btstack_tlv_posix_t *) context;
|
||||
|
||||
// enforce arbitrary max value size
|
||||
btstack_assert(data_size <= MAX_TLV_VALUE_SIZE);
|
||||
|
||||
// remove old entry
|
||||
tlv_entry_t * old_entry = btstack_tlv_posix_find_entry(self, tag);
|
||||
if (old_entry){
|
||||
@ -193,8 +199,8 @@ static int btstack_tlv_posix_read_db(btstack_tlv_posix_t * self){
|
||||
uint32_t tag = big_endian_read_32(entry, 0);
|
||||
uint32_t len = big_endian_read_32(entry, 4);
|
||||
|
||||
// arbitrary safety check: values < 1000 bytes each
|
||||
if (len > 1000) break;
|
||||
// arbitrary safety check: values <= MAX_TLV_VALUE_SIZE
|
||||
if (len > MAX_TLV_VALUE_SIZE) break;
|
||||
|
||||
// create new entry for regular tag
|
||||
tlv_entry_t * new_entry = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user