linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Grzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 5/6] android/hal-mce: Add event handler
Date: Fri, 03 Oct 2014 13:34:55 +0200	[thread overview]
Message-ID: <2130454.YRCQC94hdb@uw000953> (raw)
In-Reply-To: <1411383708-28621-5-git-send-email-grzegorz.kolodziejczyk@tieto.com>

Hi Grzegorz,

On Monday 22 of September 2014 13:01:47 Grzegorz Kolodziejczyk wrote:
> ---
>  android/hal-map-client.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/android/hal-map-client.c b/android/hal-map-client.c
> index 7fb3011..7538958 100644
> --- a/android/hal-map-client.c
> +++ b/android/hal-map-client.c
> @@ -15,6 +15,7 @@
>   *
>   */
>  
> +#include <stdlib.h>
>  #include <stdbool.h>
>  
>  #include "hal-log.h"
> @@ -31,9 +32,55 @@ static bool interface_ready(void)
>  
>  /* Event Handlers */
>  
> +static void remote_mas_instances_to_hal(btmce_mas_instance_t *send_instance,
> +				struct hal_map_client_mas_instance *instance,
> +				uint8_t num_instances, uint16_t len)
> +{
> +	void *buf = instance;
> +	uint8_t i;
> +
> +	DBG("");
> +
> +	for (i = 0; i < num_instances; i++) {
> +		if (sizeof(*instance) + instance->name_len > len) {
> +			error("invalid remote mas instances (%zu > %u),"
> +				"aborting",

Try not to break strings ie. make this shorter by removing 'remote'.

> +				sizeof(*instance) + instance->name_len, len);
> +			exit(EXIT_FAILURE);
> +		}
> +
> +		send_instance[i].id = instance->id;
> +		send_instance[i].msg_types = instance->msg_types;
> +		send_instance[i].scn = instance->scn;
> +		send_instance[i].p_name = (char *) instance->name;

You should check if name is NULL terminated and abort if not.
Check handle_dial() in hal-handsfree for reference.

> +
> +		len -= sizeof(*instance) + instance->name_len;
> +		buf += sizeof(*instance) + instance->name_len;
> +		instance = buf;
> +	}
> +
> +	if (!len)
> +		return;
> +
> +	error("invalid remote mas instances (%u bytes left), aborting", len);
> +	exit(EXIT_FAILURE);
> +}
> +
>  static void handle_remote_mas_instances(void *buf, uint16_t len, int fd)
>  {
> +	struct hal_ev_map_client_remote_mas_instances *ev = buf;
> +	btmce_mas_instance_t instances[ev->num_instances];
> +
> +	DBG("");
> +
> +	len -= sizeof(*ev);
> +	remote_mas_instances_to_hal(instances, ev->instances, ev->num_instances,
> +									len);
>  
> +	if (cbs->remote_mas_instances_cb)
> +		cbs->remote_mas_instances_cb(ev->status,
> +						(bt_bdaddr_t *) ev->bdaddr,
> +						ev->num_instances, instances);
>  }
>  
>  /* handlers will be called from notification thread context,
> 

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2014-10-03 11:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 11:01 [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 2/6] android/hal-mce-api: Add get remote MAS instance command and event Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 3/6] android/mce: Add Android MCE header Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 4/6] android/hal-mce: Add skeleton for MCE HAL Grzegorz Kolodziejczyk
2014-10-03 11:26   ` Szymon Janc
2014-10-03 11:30     ` Grzegorz Kolodziejczyk
2014-09-22 11:01 ` [PATCH 5/6] android/hal-mce: Add event handler Grzegorz Kolodziejczyk
2014-10-03 11:34   ` Szymon Janc [this message]
2014-09-22 11:01 ` [PATCH 6/6] android/hal-mce: Add API calls Grzegorz Kolodziejczyk
2014-10-02 20:49 ` [PATCH 1/6] android/hal-ipc-api: Add MCE HAL Lukasz Rymanowski
2014-10-03 11:17 ` Szymon Janc
2014-10-03 11:38 ` Szymon Janc

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=2130454.YRCQC94hdb@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=grzegorz.kolodziejczyk@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).