diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-05-30 14:33:09 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-05-30 14:35:24 +0100 |
commit | ad6ea7755828ded65e257c4bfb6b3f2a806e43ca (patch) | |
tree | 977c034562f3dd04a8d1caeb7317b555af186ba4 /tests | |
parent | 648191a1990e5959610fb6592b01c40e583cf810 (diff) |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gvariant-lookup.c | 21 |
1 files changed, 21 insertions, 0 deletions
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); +} |