mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
auto-pts: enable address sanitizer, assert response_buffer doesn't overflow
This commit is contained in:
parent
fc823f601c
commit
6914a89114
@ -62,6 +62,9 @@ set(SOURCES
|
||||
${SOURCES_ZEPHYR}
|
||||
)
|
||||
|
||||
add_compile_options( -fsanitize=address)
|
||||
add_link_options( -fsanitize=address)
|
||||
|
||||
# create static lib
|
||||
add_library(btstack STATIC ${SOURCES})
|
||||
|
||||
|
@ -432,16 +432,22 @@ static void sm_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
}
|
||||
}
|
||||
|
||||
static void btp_append_assert(uint16_t num_bytes_to_append){
|
||||
btstack_assert((response_len + num_bytes_to_append) <= sizeof(response_buffer));
|
||||
}
|
||||
static void btp_append_uint8(uint8_t uint){
|
||||
btp_append_assert(1);
|
||||
response_buffer[response_len++] = uint;
|
||||
}
|
||||
|
||||
static void btp_append_uint16(uint16_t uint){
|
||||
btp_append_assert(2);
|
||||
little_endian_store_16(response_buffer, response_len, uint);
|
||||
response_len += 2;
|
||||
}
|
||||
|
||||
static void btp_append_blob(uint16_t len, const uint8_t * data){
|
||||
btp_append_assert(len);
|
||||
memcpy(&response_buffer[response_len], data, len);
|
||||
response_len += len;
|
||||
}
|
||||
@ -449,6 +455,7 @@ static void btp_append_blob(uint16_t len, const uint8_t * data){
|
||||
static void btp_append_uuid(uint16_t uuid16, const uint8_t * uuid128){
|
||||
if (uuid16 == 0){
|
||||
btp_append_uint8(16);
|
||||
btp_append_assert(16);
|
||||
reverse_128(uuid128, &response_buffer[response_len]);
|
||||
response_len += 16;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user