summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-10-22 15:28:31 +0300
committerJohan Hedberg <johan.hedberg@nokia.com>2008-10-22 15:28:31 +0300
commit29b082c2d9508f624ffca920cd92ec1e966cab07 (patch)
treeb24e832ca9f4b4316d113ba5cc1008d52ffa132b /audio
parent847808fe3dd67947b3de35f65704fd1ddfb2e163 (diff)
Return proper error replies in telephony-dummy
Without this fix sending invalid arguments to telephony-dummy causes libgdbus to return NO_MEMORY to libdbus which in turn causes the method handler to be called in an infinite loop.
Diffstat (limited to 'audio')
-rw-r--r--audio/telephony-dummy.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c
index 66873b65..b857183f 100644
--- a/audio/telephony-dummy.c
+++ b/audio/telephony-dummy.c
@@ -64,6 +64,12 @@ static struct indicator dummy_indicators[] =
{ NULL }
};
+static inline DBusMessage *invalid_args(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
+ "Invalid arguments in method call");
+}
+
void telephony_device_connected(void *telephony_device)
{
debug("telephony-dummy: device %p connected", telephony_device);
@@ -198,7 +204,7 @@ static DBusMessage *outgoing_call(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
debug("telephony-dummy: outgoing call to %s", number);
@@ -223,7 +229,7 @@ static DBusMessage *incoming_call(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
debug("telephony-dummy: incoming call to %s", number);
@@ -269,10 +275,10 @@ static DBusMessage *signal_strength(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &strength,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
if (strength > 5)
- return NULL;
+ return invalid_args(msg);
telephony_update_indicator(dummy_indicators, "signal", strength);
@@ -288,10 +294,10 @@ static DBusMessage *battery_level(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &level,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
if (level > 5)
- return NULL;
+ return invalid_args(msg);
telephony_update_indicator(dummy_indicators, "battchg", level);
@@ -308,7 +314,7 @@ static DBusMessage *roaming_status(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &roaming,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
val = roaming ? EV_ROAM_ACTIVE : EV_ROAM_INACTIVE;
@@ -327,7 +333,7 @@ static DBusMessage *registration_status(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &registration,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
val = registration ? EV_SERVICE_PRESENT : EV_SERVICE_NONE;
@@ -346,7 +352,7 @@ static DBusMessage *set_subscriber_number(DBusConnection *conn,
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &number,
DBUS_TYPE_INVALID))
- return NULL;
+ return invalid_args(msg);
g_free(subscriber_number);
subscriber_number = g_strdup(number);