GNOME Bugzilla – Bug 343562
Garbage in dialog when error occurs while trying to play a song
Last modified: 2006-08-16 01:29:50 UTC
In the function rb_shell_player_cmd_play(), if an error occur when calling rb_shell_player_playpause(), a dialog is displayed using rb_error_dialog(). However, the first string passed to this function contains a "%s" escape sequence, even tough is is later passed to gtk_message_dialog_new() without further arguments, and thus interpreting a random address in memory as a string, which can lead to crash or whatever ... The two attached patch correct this problem, first by changing the string passed to rb_error_dialog() to remove the "%s" sequence, and then by changing the call to gtk_message_dialog_new() in rb_error_dialog() to not interpret %-escape sequences in primary string.
Created attachment 66579 [details] [review] No longer interpret %-escape sequence in primary Well, I promised two patch, but there will only be one. The two changes are incoporated in this single patch.
Created attachment 66627 [details] [review] more format string problems This fixes all other instances of the same mistake, marks the rb_dialog functions as taking format string args so gcc will help catch future problems, and then does the same for rb_debug.
Looks great to me, except that it probably needs something so that it works on non-GCC compilers. Putting the following somewhere will probably work. #ifndef G_GNUC_PRINTF #define G_GNUC_PRINTF (a,b) #endif
Concerning G_GNUC_PRINTF, this is already a macro defined by glib [1] to expand to the correct syntax if the compiler used is gcc, and to nothing if it isn't, so adding the #ifndef ... is not necessary. [1] http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Macros.html#id3046072 Concerning the second patch, it has removed my modification to rb_error_dialog() that protected the call to gtk_message_dialog_new() against %-escape sequence in the primary parameter. Better safe than sorry :-)
Oups, sorry the link should have been [1]. Sorry for the spam. [1] http://developer.gnome.org/doc/API/2.0/glib/glib-Miscellaneous-Macros.html#id3045876
Good point, I hadn't noticed that it was a glib macro. AFAICT the rb_error_dialog change is still in the patch.
Committed to cvs.
*** Bug 351526 has been marked as a duplicate of this bug. ***