components/bt: Fix the strlcpy length error in BTA_HfClientSendAT

pull/8755/head
baohongde 2022-03-25 16:21:46 +08:00
rodzic 9fea2a19c1
commit 8a2abff26d
3 zmienionych plików z 10 dodań i 3 usunięć

Wyświetl plik

@ -284,8 +284,13 @@ void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val
p_buf->uint32_val2 = val2;
if (str) {
strlcpy(p_buf->str, str, BTA_HF_CLIENT_NUMBER_LEN + 1);
p_buf->str[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
UINT32 str_len = strlen(str);
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 {
p_buf->str[0] = '\0';
}

Wyświetl plik

@ -117,7 +117,7 @@ typedef struct {
UINT8 uint8_val;
UINT32 uint32_val1;
UINT32 uint32_val2;
char str[BTA_HF_CLIENT_NUMBER_LEN + 1];
char str[BTA_HF_CLIENT_MAX_LEN + 1];
} tBTA_HF_CLIENT_DATA_VAL;
/* union of all event datatypes */

Wyświetl plik

@ -156,6 +156,8 @@ typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
#define BTA_HF_CLIENT_MAX_LEN 32
/* data associated with most non-AT events */
/* placeholder, if not needed should be removed*/
typedef struct {