forked from espressif/esp-idf
components/bt: Fix the strlcpy length error in BTA_HfClientSendAT
This commit is contained in:
@@ -284,8 +284,13 @@ void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val
|
|||||||
p_buf->uint32_val2 = val2;
|
p_buf->uint32_val2 = val2;
|
||||||
|
|
||||||
if (str) {
|
if (str) {
|
||||||
strlcpy(p_buf->str, str, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
UINT32 str_len = strlen(str);
|
||||||
p_buf->str[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
if (str_len > BTA_HF_CLIENT_MAX_LEN) {
|
||||||
|
APPL_TRACE_WARNING("%s, str length(%d) is more than %d, truncate it.", __FUNCTION__, str_len, BTA_HF_CLIENT_MAX_LEN);
|
||||||
|
str_len = BTA_HF_CLIENT_MAX_LEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcpy(p_buf->str, str, str_len + 1);
|
||||||
} else {
|
} else {
|
||||||
p_buf->str[0] = '\0';
|
p_buf->str[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@@ -117,7 +117,7 @@ typedef struct {
|
|||||||
UINT8 uint8_val;
|
UINT8 uint8_val;
|
||||||
UINT32 uint32_val1;
|
UINT32 uint32_val1;
|
||||||
UINT32 uint32_val2;
|
UINT32 uint32_val2;
|
||||||
char str[BTA_HF_CLIENT_NUMBER_LEN + 1];
|
char str[BTA_HF_CLIENT_MAX_LEN + 1];
|
||||||
} tBTA_HF_CLIENT_DATA_VAL;
|
} tBTA_HF_CLIENT_DATA_VAL;
|
||||||
|
|
||||||
/* union of all event datatypes */
|
/* union of all event datatypes */
|
||||||
|
@@ -156,6 +156,8 @@ typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
|
|||||||
|
|
||||||
typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
|
typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
|
||||||
|
|
||||||
|
#define BTA_HF_CLIENT_MAX_LEN 32
|
||||||
|
|
||||||
/* data associated with most non-AT events */
|
/* data associated with most non-AT events */
|
||||||
/* placeholder, if not needed should be removed*/
|
/* placeholder, if not needed should be removed*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Reference in New Issue
Block a user