GNOME Bugzilla – Bug 652025
g_dbus_connection_register_object: error is not set when !g_variant_is_object_path(object_path)
Last modified: 2011-06-09 06:12:33 UTC
Created attachment 189376 [details] test code for invalid application id this bug can easily be re-produced with invalid application_id to g_application_new() and call g_application_run(). from the code path from g_application_run(), it goes down to the g_dbus_connection_register_object() and checks to see the given object_path is actually a valid "object path" with g_variant_is_object_path() in g_return_val_if_fail macro at the very beginning of the function. if the given object_path is not valid, meaning having "-" for example, it will return to g_application_impl_register(), g_application_register(), and reach back to g_application_real_local_command_line(). in the g_application_real_local_command_line(), when g_application_register() returns false, the code assumes that the passed variable "error" is set, however, this is not the case in this code pass. what would be the best idiom to use in this case?
I think we should accept '-' and use it as a bus name (since that is allowed) but when creating the corresponding object path, change any '-' to '_'. This creates a contradiction. If someone tries to put 'org.dumb-example' and 'org.dumb_example' in the same process the API suggests that it should theoretically work, but it will actually fail. We could fix that by banning '_' in application IDs, and we'd have good reason to: it's not valid DNS.
commit f44cd4129356dd569fd90e3ea83e386bce0602a7 Author: Ryan Lortie <desrt@desrt.ca> Date: Wed Jun 8 22:21:15 2011 -0400 GApplication: allow '-' in application ID By converting it to _ before trying to shove it into an object path. https://bugzilla.gnome.org/show_bug.cgi?id=652025
btw: about the reported problem that a GError isn't returned in the error case: it is commonly true that hitting a g_critical will result in an unset GError. There are many many examples of this in GLib, and I don't think we could (or should) fix them all.
ah, ok. g_return_val_if_fail() indicates a programming error, and that means you never know what will happen after that, right? understood. and appreciate for your clarification and the fix. Thanks,