[XPCOM] Add a sanity check to ensure we don't send messages with unexpected arguments
authorKalle Vahlman <kalle.vahlman@movial.com>
Mon, 10 Nov 2008 11:04:32 +0000 (13:04 +0200)
committerKalle Vahlman <kalle.vahlman@movial.com>
Mon, 10 Nov 2008 11:04:32 +0000 (13:04 +0200)
xpcom-dbusservice/DBusMethod.cpp

index 6fd0eaf..7dd03b5 100644 (file)
@@ -288,6 +288,17 @@ DBusMethod::DoCall(nsIVariant **aArgs, PRUint32 aCount)
         return NS_ERROR_ILLEGAL_VALUE;
     }
 
+    // Sanity-check: make sure that the signature we think we are sending matches
+    // that of the message
+    
+    if (!signature.Equals(dbus_message_get_signature(msg)))
+    {
+        BDBLOG(("  signature mismatch! Expected '%s', got '%s'\n",
+                PromiseFlatCString(signature).get(),
+                dbus_message_get_signature(msg)));
+        return NS_ERROR_ILLEGAL_VALUE;
+    }
+
     DBusPendingCall *pending = mDBusService->SendWithReply(mBusType,
                                                            msg,
                                                            -1);