Skip to contentSkip to conversation

Add argument verification when unregistering Handsfree agent

PATCH In review Claudio Takahasi 2 participants 2 messages Feb 9, 2010 – Feb 10, 2010 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add argument verification when unregistering Handsfree agent

Hi,

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

Regards,
Claudio.

From 812c3902fa58f311c3744b9d9ab893d818fc069c Mon Sep 17 00:00:00 2001
From: Claudio Takahasi <[email protected]>
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(-)
audio/gateway.c +14 -1
index 8150a5e..b043e24 100644
@@ -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);
 
doc/hfp-api.txt +4 -0
index 8180de0..93251e8 100644
@@ -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
Signature · 1 line
1.6.6.1
#1 lore raw

Hi Claudio,

Quoted 2 lines · Claudio Takahasi

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

Thanks. The patch has been pushed upstream.

Johan