From: Szymon Janc <szymon.janc@tieto.com>
To: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 02/11] android/hidhost: Fix miscalculation of get report event struct length
Date: Mon, 20 Jan 2014 16:22:35 +0100 [thread overview]
Message-ID: <2481120.IZcvT0pjE9@uw000953> (raw)
In-Reply-To: <1389914751-18545-3-git-send-email-ravikumar.veeramally@linux.intel.com>
Hi Ravi,
On Friday 17 of January 2014 01:25:42 Ravi kumar Veeramally wrote:
> ---
> android/hal-hidhost.c | 3 ++-
> android/hidhost.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
> index fd3ad2d..5445d08 100644
> --- a/android/hal-hidhost.c
> +++ b/android/hal-hidhost.c
> @@ -73,7 +73,8 @@ static void handle_get_report(void *buf, uint16_t len)
> {
> struct hal_ev_hidhost_get_report *ev = buf;
>
> - if (len != sizeof(*ev) + ev->len) {
> + if (len != sizeof(*ev) + sizeof(struct hal_ev_hidhost_get_report)
> + + ev->len) {
I don't understand this change. We have header and data len. There should be
no need for any extra calculations.
> error("invalid get report event, aborting");
> exit(EXIT_FAILURE);
> }
> diff --git a/android/hidhost.c b/android/hidhost.c
> index c004063..8a2668c 100644
> --- a/android/hidhost.c
> +++ b/android/hidhost.c
> @@ -371,13 +371,14 @@ static void bt_hid_notify_get_report(struct hid_device *dev, uint8_t *buf,
> ba2str(&dev->dst, address);
> DBG("device %s", address);
>
> - ev_len = sizeof(*ev) + sizeof(struct hal_ev_hidhost_get_report) + 1;
> + ev_len = sizeof(*ev) + sizeof(struct hal_ev_hidhost_get_report);
I don't understand why there is double sizeof() in first place.(*ev is same type)
>
> if (!((buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_INPUT)) ||
> (buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_OUTPUT)) ||
> (buf[0] == (HID_MSG_DATA | HID_DATA_TYPE_FEATURE)))) {
> ev = g_malloc0(ev_len);
> ev->status = buf[0];
> + ev->len = 0;
> bdaddr2android(&dev->dst, ev->bdaddr);
> goto send;
> }
I have a feeling that there is something wrong with ev_len calculations in
bt_hid_notify_get_report(). I'd rather prefer to have this function properly
fixed (and possibly refactored on how it handles ev data allocation).
--
Best regards,
Szymon Janc
next prev parent reply other threads:[~2014-01-20 15:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-16 23:25 [PATCH 00/11] HIDHost E2E tests and fixes Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 01/11] android/hidhost: Fix connection state notification on profile unregister Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 02/11] android/hidhost: Fix miscalculation of get report event struct length Ravi kumar Veeramally
2014-01-20 15:22 ` Szymon Janc [this message]
2014-01-16 23:25 ` [PATCH 03/11] android/hidhost: Remove unnecessary check Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 04/11] android/tester: Add HIDhost Connect test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 05/11] android/tester: Add HIDhost Disconnect test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 06/11] android/tester: Add HIDhost VirtualUnplug test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 07/11] android/tester: Add HIDhost GetProtocol test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 08/11] android/tester: Add HIDhost SetProtocol test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 09/11] android/tester: Add HIDhost GetReport test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 10/11] android/tester: Add HIDhost SetReport test Ravi kumar Veeramally
2014-01-16 23:25 ` [PATCH 11/11] android/tester: Add HIDhost SendData test Ravi kumar Veeramally
2014-01-20 15:30 ` [PATCH 00/11] HIDHost E2E tests and fixes Szymon Janc
2014-01-20 18:08 ` Ravi kumar Veeramally
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2481120.IZcvT0pjE9@uw000953 \
--to=szymon.janc@tieto.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=ravikumar.veeramally@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox