Skip to content

Commit

Permalink
fix(bt/bluedroid): Added some argument check in APIs of HFP AG
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterJincheng committed Nov 20, 2023
1 parent fcd0b8b commit e4ab449
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/bt/host/bluedroid/api/esp_hf_ag_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ esp_err_t esp_hf_ag_volume_control(esp_bd_addr_t remote_addr, esp_hf_volume_cont
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (volume < 0 || volume > 15) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF;
Expand Down Expand Up @@ -237,6 +240,9 @@ esp_err_t esp_hf_ag_devices_status_indchange(esp_bd_addr_t remote_addr,
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (signal < 0 || signal > 5) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF;
Expand Down Expand Up @@ -285,6 +291,10 @@ esp_err_t esp_hf_ag_cind_response(esp_bd_addr_t remote_addr,
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (signal < 0 || signal > 5 || batt_lev < 0 || batt_lev > 5) {
return ESP_ERR_INVALID_ARG;
}

btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_HF;
Expand Down Expand Up @@ -363,7 +373,7 @@ esp_err_t esp_hf_ag_cnum_response(esp_bd_addr_t remote_addr, char *number, int n
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (number == NULL) {
if (number == NULL || number_type < 128 || number_type > 175) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
Expand Down
4 changes: 4 additions & 0 deletions components/bt/host/bluedroid/api/include/api/esp_hf_ag_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ esp_err_t esp_hf_ag_vra_control(esp_bd_addr_t remote_bda, esp_hf_vr_state_t valu
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_ERR_INVALID_ARG: if arguments are invalid
* - ESP_FAIL: others
*
*/
Expand Down Expand Up @@ -448,6 +449,7 @@ esp_err_t esp_hf_ag_cmee_send(esp_bd_addr_t remote_bda, esp_hf_at_response_code_
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_ERR_INVALID_ARG: if arguments are invalid
* - ESP_FAIL: others
*
*/
Expand Down Expand Up @@ -490,6 +492,7 @@ esp_err_t esp_hf_ag_ciev_report(esp_bd_addr_t remote_addr, esp_hf_ciev_report_ty
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_ERR_INVALID_ARG: if the arguments are invalid
* - ESP_FAIL: others
*
*/
Expand Down Expand Up @@ -567,6 +570,7 @@ esp_err_t esp_hf_ag_cnum_response(esp_bd_addr_t remote_addr, char *number, int n
* @return
* - ESP_OK: disconnect request is sent to lower layer
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_ERR_INVALID_ARG: if arguments are invalid
* - ESP_FAIL: others
*
*/
Expand Down

0 comments on commit e4ab449

Please sign in to comment.