From cc2af09f608511bf316e94e4462ff041406c455b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 Sep 2013 13:07:57 +0000 Subject: Flag printf-ish functions with G_GNUC_PRINTF and fix resulting warnings In particular, mcd-account-manager-default could crash when migrating an account, since it would dereference arbitrary stack contents as a pointer-to-string. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69542 Reviewed-by: Guillaume Desmottes --- Index: telepathy-mission-control-5-5.14.1/src/mcd-account-manager-default.c =================================================================== --- telepathy-mission-control-5-5.14.1.orig/src/mcd-account-manager-default.c 2013-11-12 19:48:15.286396705 +0100 +++ telepathy-mission-control-5-5.14.1/src/mcd-account-manager-default.c 2013-11-12 19:48:15.274396705 +0100 @@ -777,7 +777,8 @@ if (_commit (self, am, NULL)) { - DEBUG ("Migrated %s to new location: deleting old copy"); + DEBUG ("Migrated %s to new location: deleting old copy", + old_filename); if (g_unlink (old_filename) != 0) g_warning ("Unable to delete %s: %s", old_filename, g_strerror (errno)); Index: telepathy-mission-control-5-5.14.1/src/mcd-account.c =================================================================== --- telepathy-mission-control-5-5.14.1.orig/src/mcd-account.c 2013-11-12 19:48:15.286396705 +0100 +++ telepathy-mission-control-5-5.14.1/src/mcd-account.c 2013-11-12 19:48:15.278396705 +0100 @@ -2422,7 +2422,7 @@ g_hash_table_iter_init (&iter, dbus_properties); while (g_hash_table_iter_next (&iter, &name, &value)) { - DEBUG ("updating parameter %s", name); + DEBUG ("updating parameter %s", (const gchar *) name); _mcd_connection_update_property (priv->connection, name, value); } } Index: telepathy-mission-control-5-5.14.1/src/mcd-debug.h =================================================================== --- telepathy-mission-control-5-5.14.1.orig/src/mcd-debug.h 2013-11-12 19:48:15.286396705 +0100 +++ telepathy-mission-control-5-5.14.1/src/mcd-debug.h 2013-11-12 19:48:15.278396705 +0100 @@ -59,7 +59,7 @@ void mcd_debug_print_tree (gpointer obj); -void mcd_debug (const gchar *format, ...); +void mcd_debug (const gchar *format, ...) G_GNUC_PRINTF (1, 2); G_END_DECLS Index: telepathy-mission-control-5-5.14.1/src/mcd-dispatcher.c =================================================================== --- telepathy-mission-control-5-5.14.1.orig/src/mcd-dispatcher.c 2013-11-12 19:48:15.286396705 +0100 +++ telepathy-mission-control-5-5.14.1/src/mcd-dispatcher.c 2013-11-12 19:48:15.282396705 +0100 @@ -2034,7 +2034,7 @@ g_strdup (mcd_channel_get_object_path (to_delegate->channel)), v); - DEBUG ("...but failed to delegate it: %s", + DEBUG ("...but failed to delegate %s: %s", mcd_channel_get_object_path (to_delegate->channel), to_delegate->error->message); Index: telepathy-mission-control-5-5.14.1/tests/account-store.c =================================================================== --- telepathy-mission-control-5-5.14.1.orig/tests/account-store.c 2013-11-12 19:48:15.286396705 +0100 +++ telepathy-mission-control-5-5.14.1/tests/account-store.c 2013-11-12 19:48:15.282396705 +0100 @@ -87,7 +87,7 @@ }; static void usage (const gchar *name, const gchar *fmt, - ...) G_GNUC_NORETURN; + ...) G_GNUC_NORETURN G_GNUC_PRINTF (2, 3); #if ENABLE_GNOME_KEYRING #include @@ -141,7 +141,7 @@ #endif if (argc < 3) - usage (argv[0], ""); + usage (argv[0], "Not enough arguments"); op_name = argv[1]; backend = argv[2];