android/hidhost: Move get_protocol parameter check to daemon
PATCH 1/4 android/hidhost: Move get_protocol parameter check to daemon
HAL library is to be as simple as possible and parameters values should be verified by daemon for robustness anyway. Move this check to daemon.
--- android/hal-hidhost.c | 12 ++---------- android/hidhost.c | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-)
android/hal-hidhost.c +2 -10
@@ -218,16 +218,8 @@ static bt_status_t get_protocol(bt_bdaddr_t *bd_addr,memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); -switch (protocol_mode) { -case BTHH_REPORT_MODE : - cmd.mode =HAL_HIDHOST_REPORT_PROTOCOL ; -break ; -case BTHH_BOOT_MODE : - cmd.mode =HAL_HIDHOST_BOOT_PROTOCOL ; -break ; -default : -return BT_STATUS_PARM_INVALID ; - } +/* type match IPC type */ + cmd.mode = protocol_mode; return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_GET_PROTOCOL,
android/hidhost.c +9 -0
@@ -880,6 +880,15 @@ static void bt_hid_get_protocol(const void *buf, uint16_t len)DBG ("" ); +switch (cmd->mode) { +case HAL_HIDHOST_REPORT_PROTOCOL : +case HAL_HIDHOST_BOOT_PROTOCOL : +break ; +default : + status =HAL_STATUS_INVALID ; + goto failed; + } +android2bdaddr (&cmd->bdaddr, &dst); l =g_slist_find_custom (devices, &dst, device_cmp);
Signature · 1 line
1.8.5.2
PATCH 2/4 android/hidhost: Move set_protocol parameter check to daemon
HAL library is to be as simple as possible and parameters values should be verified by daemon for robustness anyway. Move this check to daemon.
--- android/hal-hidhost.c | 12 ++---------- android/hidhost.c | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-)
android/hal-hidhost.c +2 -10
@@ -241,16 +241,8 @@ static bt_status_t set_protocol(bt_bdaddr_t *bd_addr,memcpy (cmd.bdaddr, bd_addr,sizeof (cmd.bdaddr)); -switch (protocol_mode) { -case BTHH_REPORT_MODE : - cmd.mode =HAL_HIDHOST_REPORT_PROTOCOL ; -break ; -case BTHH_BOOT_MODE : - cmd.mode =HAL_HIDHOST_BOOT_PROTOCOL ; -break ; -default : -return BT_STATUS_PARM_INVALID ; - } +/* type match IPC type */ + cmd.mode = protocol_mode; return hal_ipc_cmd(HAL_SERVICE_ID_HIDHOST, HAL_OP_HIDHOST_SET_PROTOCOL,
android/hidhost.c +9 -0
@@ -935,6 +935,15 @@ static void bt_hid_set_protocol(const void *buf, uint16_t len)DBG ("" ); +switch (cmd->mode) { +case HAL_HIDHOST_REPORT_PROTOCOL : +case HAL_HIDHOST_BOOT_PROTOCOL : +break ; +default : + status =HAL_STATUS_INVALID ; + goto failed; + } +android2bdaddr (&cmd->bdaddr, &dst); l =g_slist_find_custom (devices, &dst, device_cmp);
Signature · 1 line
1.8.5.2
PATCH 3/4 android/hidhost: Move get_report parameter check to daemon
In reply to Szymon JancHAL library is to be as simple as possible and parameters values should be verified by daemon for robustness anyway. Move this check to daemon.
--- android/hal-hidhost.c | 15 ++------------- android/hidhost.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-)
android/hal-hidhost.c +2 -13
@@ -268,19 +268,8 @@ static bt_status_t get_report(bt_bdaddr_t *bd_addr, cmd.id = report_id; cmd.buf_size = buffer_size; -switch (report_type) { -case BTHH_INPUT_REPORT : - cmd.type =HAL_HIDHOST_INPUT_REPORT ; -break ; -case BTHH_OUTPUT_REPORT : - cmd.type =HAL_HIDHOST_OUTPUT_REPORT ; -break ; -case BTHH_FEATURE_REPORT : - cmd.type =HAL_HIDHOST_FEATURE_REPORT ; -break ; -default : -return BT_STATUS_PARM_INVALID ; - } +/* type match IPC type */ + cmd.type = report_type;return hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_OP_HIDHOST_GET_REPORT ,sizeof (cmd), &cmd,0 ,NULL ,NULL );
android/hidhost.c +10 -0
@@ -991,6 +991,16 @@ static void bt_hid_get_report(const void *buf, uint16_t len)DBG ("" ); +switch (cmd->type) { +case HAL_HIDHOST_INPUT_REPORT : +case HAL_HIDHOST_OUTPUT_REPORT : +case HAL_HIDHOST_FEATURE_REPORT : +break ; +default : + status =HAL_STATUS_INVALID ; + goto failed; + } +android2bdaddr (&cmd->bdaddr, &dst); l =g_slist_find_custom (devices, &dst, device_cmp);
Signature · 1 line
1.8.5.2
PATCH 4/4 android/hidhost: Move set_report parameter check to daemon
In reply to Szymon JancHAL library is to be as simple as possible and parameters values should be verified by daemon for robustness anyway. Move this check to daemon.
--- android/hal-hidhost.c | 15 ++------------- android/hidhost.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-)
android/hal-hidhost.c +2 -13
@@ -294,19 +294,8 @@ static bt_status_t set_report(bt_bdaddr_t *bd_addr, cmd->len =strlen (report);memcpy (cmd->data, report, cmd->len); -switch (report_type) { -case BTHH_INPUT_REPORT : - cmd->type =HAL_HIDHOST_INPUT_REPORT ; -break ; -case BTHH_OUTPUT_REPORT : - cmd->type =HAL_HIDHOST_OUTPUT_REPORT ; -break ; -case BTHH_FEATURE_REPORT : - cmd->type =HAL_HIDHOST_FEATURE_REPORT ; -break ; -default : -return BT_STATUS_PARM_INVALID ; - } +/* type match IPC type */ + cmd->type = report_type;return hal_ipc_cmd (HAL_SERVICE_ID_HIDHOST ,HAL_OP_HIDHOST_SET_REPORT ,sizeof (*cmd) + cmd->len, buf,0 ,NULL ,NULL );
android/hidhost.c +10 -0
@@ -1064,6 +1064,16 @@ static void bt_hid_set_report(const void *buf, uint16_t len)return ; } +switch (cmd->type) { +case HAL_HIDHOST_INPUT_REPORT : +case HAL_HIDHOST_OUTPUT_REPORT : +case HAL_HIDHOST_FEATURE_REPORT : +break ; +default : + status =HAL_STATUS_INVALID ; + goto failed; + } +android2bdaddr (&cmd->bdaddr, &dst); l =g_slist_find_custom (devices, &dst, device_cmp);
Signature · 1 line
1.8.5.2
Hi Szymon,
Quoted 6 lines · Szymon Janc
HAL library is to be as simple as possible and parameters values should be verified by daemon for robustness anyway. Move this check to daemon.
--- android/hal-hidhost.c | 12 ++---------- android/hidhost.c | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-)
All patches in this set have been applied. Thanks.
Johan