linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
To: BlueZ development <linux-bluetooth@vger.kernel.org>
Cc: padovan@profusion.mobi
Subject: [PATCH] Add argument verification when unregistering Handsfree agent
Date: Tue, 9 Feb 2010 20:25:43 -0200	[thread overview]
Message-ID: <f9d4bd31002091425l3cf8a4e0u7e3ad0ec0f1766ec@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 140 bytes --]

Hi,

this patch fix a minor problem in the handsfree gateway/agent code:
the object path
argument is not being verified.

Regards,
Claudio.

[-- Attachment #2: 0001-Add-argument-verification-when-unregistering-Handsfr.patch --]
[-- Type: application/octet-stream, Size: 1879 bytes --]

From 812c3902fa58f311c3744b9d9ab893d818fc069c Mon Sep 17 00:00:00 2001
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
Date: Tue, 9 Feb 2010 19:36:26 -0200
Subject: [PATCH 1/1] Add argument verification when unregistering Handsfree agent

The given object path argument must match the same value that has been
used on registration.
---
 audio/gateway.c |   15 ++++++++++++++-
 doc/hfp-api.txt |    4 ++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index 8150a5e..b043e24 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -513,13 +513,26 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
 {
 	struct audio_device *device = data;
 	struct gateway *gw = device->gateway;
+	const char *path;
 
 	if (!gw->agent)
 		goto done;
 
 	if (strcmp(gw->agent->name, dbus_message_get_sender(msg)) != 0)
 		return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
-							"Permission denied");
+				"Permission denied");
+
+	if (!dbus_message_get_args(msg, NULL,
+				DBUS_TYPE_OBJECT_PATH, &path,
+				DBUS_TYPE_INVALID))
+		return g_dbus_create_error(msg,
+				ERROR_INTERFACE ".InvalidArguments",
+				"Invalid argument");
+
+	if (strcmp(gw->agent->path, path) != 0)
+		return g_dbus_create_error(msg,
+				ERROR_INTERFACE ".Failed",
+				"Unknown object path");
 
 	g_dbus_remove_watch(device->conn, gw->agent->watch);
 
diff --git a/doc/hfp-api.txt b/doc/hfp-api.txt
index 8180de0..93251e8 100644
--- a/doc/hfp-api.txt
+++ b/doc/hfp-api.txt
@@ -37,6 +37,10 @@ Methods		void Connect()
 			registered. The object path parameter must match the
 			same value that has been used on registration.
 
+			Possible Errors: org.bluez.Error.Failed
+					 org.bluez.Error.InvalidArguments
+
+
 Signals		PropertyChanged(string name, variant value)
 
 			This signal indicates a changed value of the given
-- 
1.6.6.1


             reply	other threads:[~2010-02-09 22:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09 22:25 Claudio Takahasi [this message]
2010-02-10 11:06 ` [PATCH] Add argument verification when unregistering Handsfree agent Johan Hedberg

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=f9d4bd31002091425l3cf8a4e0u7e3ad0ec0f1766ec@mail.gmail.com \
    --to=claudio.takahasi@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=padovan@profusion.mobi \
    /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).