From ff8730c49d89058d035565d53abc919da546b38c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 6 Feb 2017 13:02:22 +0000 Subject: [PATCH] tools: Improve argument validation in dbus-spam 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 https://bugs.freedesktop.org/show_bug.cgi?id=99693 --- tools/dbus-spam.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/dbus-spam.c b/tools/dbus-spam.c index 9d2b04c..192911c 100644 --- a/tools/dbus-spam.c +++ b/tools/dbus-spam.c @@ -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; -- 2.9.3