]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tools: Improve argument validation in dbus-spam
authorPhilip Withnall <withnall@endlessm.com>
Mon, 6 Feb 2017 13:02:22 +0000 (13:02 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 13 Feb 2017 14:52:19 +0000 (14:52 +0000)
Check that at most one argument which sets the payload is provided, so
the allocated payload is not overwritten and leaked.

Coverity ID: 54759

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99693
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
tools/dbus-spam.c

index 9d2b04c3c49c07c63586d548d63fcbebbd640efd..192911cbc14c2c96147a5a29606711fc554efee9 100644 (file)
@@ -179,6 +179,17 @@ dbus_test_tool_spam (int argc, char **argv)
     {
       const char *arg = argv[i];
 
+      if (payload != NULL &&
+          (strstr (arg, "--payload=") == arg ||
+           strcmp (arg, "--stdin") == 0 ||
+           strcmp (arg, "--message-stdin") == 0 ||
+           strcmp (arg, "--random-size") == 0))
+        {
+          fprintf (stderr, "At most one of --payload, --stdin, --message-stdin "
+                           "and --random-size may be specified\n\n");
+          usage (2);
+        }
+
       if (strcmp (arg, "--system") == 0)
         {
           type = DBUS_BUS_SYSTEM;