From ad6ea7755828ded65e257c4bfb6b3f2a806e43ca Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 30 May 2014 14:33:09 +0100 Subject: gvariant: Add a unit test for abusing g_variant_lookup() This is the first real bug found in the wild by Tartan, in tp-glib. --- tests/gvariant-lookup.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/gvariant-lookup.c b/tests/gvariant-lookup.c index 22f53ff..4f07e81 100644 --- a/tests/gvariant-lookup.c +++ b/tests/gvariant-lookup.c @@ -52,3 +52,24 @@ guint not_a_string; g_variant_lookup (existing_variant, "key", "s", ¬_a_string); } + +/* + * Unexpected GVariant variadic argument of type 'char *'. Either it should be removed, or a GVariant format string should be added to the format argument to use it. There is no known GVariant representation of the argument’s type, so the argument must be serialized to a GVariant-representable type first. + * "server", "&s", &server_param); + * ^ + * Unexpected GVariant variadic argument of type 'char *'. Either it should be removed, or a GVariant format string should be added to the format argument to use it. There is no known GVariant representation of the argument’s type, so the argument must be serialized to a GVariant-representable type first. + * "server", "&s", &server_param); + * ^ + * Unexpected GVariant variadic argument of type 'const gchar **' (aka 'const char **'). Either it should be removed, or a GVariant format string should be added to the format argument to use it. There is no known GVariant representation of the argument’s type, so the argument must be serialized to a GVariant-representable type first. + * "server", "&s", &server_param); + * ^ + */ +{ + /* Incorrect usage of g_variant_lookup() found in the wild in tp-glib. + * This is the first real bug Tartan found! + * (g_variant_lookup() can only look up one key, not multiple.) */ + const gchar *account_param, *server_param; + g_variant_lookup (existing_variant, + "account", "&s", &account_param, + "server", "&s", &server_param); +} -- cgit v1.2.3