linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add argument verification when unregistering Handsfree agent
@ 2010-02-09 22:25 Claudio Takahasi
  2010-02-10 11:06 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Claudio Takahasi @ 2010-02-09 22:25 UTC (permalink / raw)
  To: BlueZ development; +Cc: padovan

[-- 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-10 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-09 22:25 [PATCH] Add argument verification when unregistering Handsfree agent Claudio Takahasi
2010-02-10 11:06 ` Johan Hedberg

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).