Skip to content

Commit bdda830

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'bugfix/dont_use_flexible_arr_in_union' into 'master'
fix(bluedroid): removed the code relying on compiler-specific extension for FAM in union Closes BT-4126 See merge request espressif/esp-idf!42236
2 parents b2335eb + 5a6193a commit bdda830

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/bt/host/bluedroid/stack/include/stack/sdp_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ typedef struct {
9696
UINT8 u8; /* 8-bit integer */
9797
UINT16 u16; /* 16-bit integer */
9898
UINT32 u32; /* 32-bit integer */
99+
UINT8 array[4]; /* Variable length field */
99100
struct t_sdp_disc_attr *p_sub_attr; /* Addr of first sub-attr (list)*/
100-
UINT8 array[]; /* Variable length field */
101101
} v;
102102

103103
} tSDP_DISC_ATVAL;

components/bt/host/bluedroid/stack/sdp/sdp_utils.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,14 @@ BOOLEAN sdpu_compare_uuid_with_attr (tBT_UUID *p_btuuid, tSDP_DISC_ATTR *p_attr)
785785
} else if (p_btuuid->len == LEN_UUID_32) {
786786
return (BOOLEAN)(p_btuuid->uu.uuid32 == p_attr->attr_value.v.u32);
787787
}
788+
/* coverity[overrun-buffer-arg] */
789+
/*
790+
Event overrun-buffer-arg: Overrun of static array "&p_attr->attr_value.v.array" of size 4 bytes by passing it to a function which indexes it with argument "16U" at byte position 15
791+
FALSE-POSITIVE error from Coverity test tool. Please do NOT remove following comment.
792+
False-positive: SDP uses scratch buffer to hold the attribute value.
793+
The actual size of tSDP_DISC_ATVAL does not matter.
794+
If the array size in tSDP_DISC_ATVAL is increase, we would increase the system RAM usage unnecessarily
795+
*/
788796
else if (p_btuuid->len == LEN_UUID_128) {
789797
return (BOOLEAN)(!memcmp(p_btuuid->uu.uuid128, (void *) p_attr->attr_value.v.array, LEN_UUID_128));
790798
}

0 commit comments

Comments
 (0)