* [PATCH] avrcp: do not get fd when not connected
@ 2011-08-25 17:33 Lucas De Marchi
2011-08-26 7:27 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2011-08-25 17:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Lucas De Marchi
---
audio/control.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/audio/control.c b/audio/control.c
index 882c9fb..9990b06 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -727,7 +727,7 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
struct avrcp_header *avrcp = (void *) &buf[AVCTP_HEADER_LENGTH];
struct avrcp_spec_avc_pdu *pdu = (void *) &buf[AVCTP_HEADER_LENGTH +
AVRCP_HEADER_LENGTH];
- int sk = g_io_channel_unix_get_fd(control->io);
+ int sk;
uint16_t size;
if (control->state != AVCTP_STATE_CONNECTED)
@@ -783,6 +783,8 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
size += AVCTP_HEADER_LENGTH + AVRCP_HEADER_LENGTH +
AVRCP_SPECAVCPDU_HEADER_LENGTH;
+ sk = g_io_channel_unix_get_fd(control->io);
+
if (write(sk, buf, size) < 0)
return -errno;
--
1.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] avrcp: do not get fd when not connected
2011-08-25 17:33 [PATCH] avrcp: do not get fd when not connected Lucas De Marchi
@ 2011-08-26 7:27 ` Luiz Augusto von Dentz
2011-08-26 12:06 ` [PATCH] Fix fd usage " Lucas De Marchi
0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2011-08-26 7:27 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth
Hi Lucas,
On Thu, Aug 25, 2011 at 8:33 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> ---
> audio/control.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/audio/control.c b/audio/control.c
> index 882c9fb..9990b06 100644
> --- a/audio/control.c
> +++ b/audio/control.c
> @@ -727,7 +727,7 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
> struct avrcp_header *avrcp = (void *) &buf[AVCTP_HEADER_LENGTH];
> struct avrcp_spec_avc_pdu *pdu = (void *) &buf[AVCTP_HEADER_LENGTH +
> AVRCP_HEADER_LENGTH];
> - int sk = g_io_channel_unix_get_fd(control->io);
> + int sk;
> uint16_t size;
>
> if (control->state != AVCTP_STATE_CONNECTED)
> @@ -783,6 +783,8 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
> size += AVCTP_HEADER_LENGTH + AVRCP_HEADER_LENGTH +
> AVRCP_SPECAVCPDU_HEADER_LENGTH;
>
> + sk = g_io_channel_unix_get_fd(control->io);
> +
> if (write(sk, buf, size) < 0)
> return -errno;
>
> --
> 1.7.6
This looks like a bug, in such case we usually use 'fix' in the
description. But the patch looks good.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Fix fd usage when not connected
2011-08-26 7:27 ` Luiz Augusto von Dentz
@ 2011-08-26 12:06 ` Lucas De Marchi
2011-08-30 12:54 ` Johan Hedberg
0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2011-08-26 12:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: luiz.dentz, Lucas De Marchi
When the avctp channel is not connected, we call
g_io_channel_unix_get_fd() with a NULL pointer. Glib does not check the
pointer before dereferencing it, causing bluetoothd to segv.
Move the function call to the place it's actually needed, after the
safety checks.
---
audio/control.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/audio/control.c b/audio/control.c
index 882c9fb..9990b06 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -727,7 +727,7 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
struct avrcp_header *avrcp = (void *) &buf[AVCTP_HEADER_LENGTH];
struct avrcp_spec_avc_pdu *pdu = (void *) &buf[AVCTP_HEADER_LENGTH +
AVRCP_HEADER_LENGTH];
- int sk = g_io_channel_unix_get_fd(control->io);
+ int sk;
uint16_t size;
if (control->state != AVCTP_STATE_CONNECTED)
@@ -783,6 +783,8 @@ static int avctp_send_event(struct control *control, uint8_t id, void *data)
size += AVCTP_HEADER_LENGTH + AVRCP_HEADER_LENGTH +
AVRCP_SPECAVCPDU_HEADER_LENGTH;
+ sk = g_io_channel_unix_get_fd(control->io);
+
if (write(sk, buf, size) < 0)
return -errno;
--
1.7.6.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix fd usage when not connected
2011-08-26 12:06 ` [PATCH] Fix fd usage " Lucas De Marchi
@ 2011-08-30 12:54 ` Johan Hedberg
0 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-08-30 12:54 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: linux-bluetooth, luiz.dentz
Hi Lucas,
On Fri, Aug 26, 2011, Lucas De Marchi wrote:
> When the avctp channel is not connected, we call
> g_io_channel_unix_get_fd() with a NULL pointer. Glib does not check the
> pointer before dereferencing it, causing bluetoothd to segv.
>
> Move the function call to the place it's actually needed, after the
> safety checks.
> ---
> audio/control.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-30 12:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25 17:33 [PATCH] avrcp: do not get fd when not connected Lucas De Marchi
2011-08-26 7:27 ` Luiz Augusto von Dentz
2011-08-26 12:06 ` [PATCH] Fix fd usage " Lucas De Marchi
2011-08-30 12:54 ` Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.