From: Philip Withnall Date: Mon, 6 Feb 2017 13:02:22 +0000 (+0000) Subject: tools: Improve argument validation in dbus-spam X-Git-Tag: dbus-1.11.10~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8af4ad5259058eafc537f21148f167f4920b5bc;p=thirdparty%2Fdbus.git 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 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99693 Reviewed-by: Simon McVittie --- diff --git a/tools/dbus-spam.c b/tools/dbus-spam.c index 9d2b04c3c..192911cbc 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;