Verify argument type before processing
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 21 Jan 2009 00:36:32 +0000 (01:36 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 21 Jan 2009 00:36:32 +0000 (01:36 +0100)
src/connection.c
src/device.c
src/network.c

index 980b770..f617dde 100644 (file)
@@ -291,6 +291,7 @@ static DBusMessage *set_property(DBusConnection *conn,
 {
        DBusMessageIter iter, value;
        const char *name;
+       int type;
 
        DBG("conn %p", conn);
 
@@ -305,6 +306,8 @@ static DBusMessage *set_property(DBusConnection *conn,
                                        CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
                return __connman_error_permission_denied(msg);
 
+       type = dbus_message_iter_get_arg_type(&value);
+
        return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
index cc5b761..6e2575b 100644 (file)
@@ -317,6 +317,7 @@ static DBusMessage *set_property(DBusConnection *conn,
        struct connman_device *device = data;
        DBusMessageIter iter, value;
        const char *name;
+       int type;
 
        DBG("conn %p", conn);
 
@@ -331,10 +332,15 @@ static DBusMessage *set_property(DBusConnection *conn,
                                        CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
                return __connman_error_permission_denied(msg);
 
+       type = dbus_message_iter_get_arg_type(&value);
+
        if (g_str_equal(name, "Powered") == TRUE) {
                connman_bool_t powered;
                int err;
 
+               if (type != DBUS_TYPE_BOOLEAN)
+                       return __connman_error_invalid_arguments(msg);
+
                dbus_message_iter_get_basic(&value, &powered);
 
                if (device->powered == powered)
@@ -348,6 +354,9 @@ static DBusMessage *set_property(DBusConnection *conn,
                const char *str;
                int err;
 
+               if (type != DBUS_TYPE_STRING)
+                       return __connman_error_invalid_arguments(msg);
+
                dbus_message_iter_get_basic(&value, &str);
                policy = string2policy(str);
                if (policy == CONNMAN_DEVICE_POLICY_UNKNOWN)
@@ -359,6 +368,9 @@ static DBusMessage *set_property(DBusConnection *conn,
        } else if (g_str_equal(name, "Priority") == TRUE) {
                connman_uint8_t priority;
 
+               if (type != DBUS_TYPE_BYTE)
+                       return __connman_error_invalid_arguments(msg);
+
                dbus_message_iter_get_basic(&value, &priority);
 
                device->priority = priority;
index 1e616e4..3e27e7e 100644 (file)
@@ -158,6 +158,7 @@ static DBusMessage *set_property(DBusConnection *conn,
        struct connman_network *network = data;
        DBusMessageIter iter, value;
        const char *name;
+       int type;
 
        DBG("conn %p", conn);
 
@@ -172,9 +173,14 @@ static DBusMessage *set_property(DBusConnection *conn,
                                        CONNMAN_SECURITY_PRIVILEGE_MODIFY) < 0)
                return __connman_error_permission_denied(msg);
 
+       type = dbus_message_iter_get_arg_type(&value);
+
        if (g_str_equal(name, "Remember") == TRUE) {
                connman_bool_t remember;
 
+               if (type != DBUS_TYPE_BOOLEAN)
+                       return __connman_error_invalid_arguments(msg);
+
                dbus_message_iter_get_basic(&value, &remember);
 
                if (network->remember == remember)
@@ -184,6 +190,9 @@ static DBusMessage *set_property(DBusConnection *conn,
        } else if (g_str_equal(name, "WiFi.Passphrase") == TRUE) {
                const char *passphrase;
 
+               if (type != DBUS_TYPE_STRING)
+                       return __connman_error_invalid_arguments(msg);
+
                if (__connman_security_check_privilege(msg,
                                        CONNMAN_SECURITY_PRIVILEGE_SECRET) < 0)
                        return __connman_error_permission_denied(msg);
@@ -195,6 +204,9 @@ static DBusMessage *set_property(DBusConnection *conn,
        } else if (g_str_equal(name, "Priority") == TRUE) {
                connman_uint8_t priority;
 
+               if (type != DBUS_TYPE_BYTE)
+                       return __connman_error_invalid_arguments(msg);
+
                dbus_message_iter_get_basic(&value, &priority);
 
                network->priority = priority;