gdbus-tool: Check return value of strrchr()

Fixes a crash when invoking gdbus like:

$ gdbus emit --session -o / -s Foo

https://bugzilla.gnome.org/show_bug.cgi?id=682965
This commit is contained in:
Rui Matos 2012-08-29 19:18:45 +02:00
parent 5328f760ee
commit 88d181ef18

View File

@ -625,7 +625,13 @@ handle_emit (gint *argc,
g_printerr (_("Error: signal not specified.\n"));
goto out;
}
s = strrchr (opt_emit_signal, '.');
if (s == NULL)
{
g_printerr (_("Error: signal must be the fully-qualified name.\n"));
goto out;
}
signal_name = g_strdup (s + 1);
interface_name = g_strndup (opt_emit_signal, s - opt_emit_signal);