From dec4423a9d4fd4e9b8b07a12a2f993b37c783ab8 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Thu, 23 Mar 2017 11:58:41 +0000 Subject: [PATCH] nm-manager: Use g_dbus_message_new_method_error_literal() GLib 2.52 added a G_GNUC_PRINTF attribute to g_dbus_message_new_method_error(). This triggered warning in NetworkManager when built with -Wformat, which is an error when built with -Werror=format-security. It seems that gcc isn't smart enough to see that (foo = "bar") should be treated as a literal. Fortunately there is a g_dbus_message_new_method_error_literal() function which does not take printf-style arguments, and we don't need them, so we can use that. This patch was originally by Rico Tzschichholz , and was submitted to Launchpad at https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1650972 https://bugzilla.gnome.org/show_bug.cgi?id=780444 (cherry picked from commit 6a77258f4ec23cfe15d944d0f106118a96c6f780) (cherry picked from commit 1715ec53c1f6ceb5635d930100f2fe06fa9d130e) --- src/nm-manager.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index 3fa66225d5..ebcd8a0787 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -4898,9 +4898,9 @@ prop_set_auth_done_cb (NMAuthChain *chain, priv->auth_chains = g_slist_remove (priv->auth_chains, chain); result = nm_auth_chain_get_result (chain, pfd->permission); if (error || (result != NM_AUTH_CALL_RESULT_YES)) { - reply = g_dbus_message_new_method_error (pfd->message, - NM_PERM_DENIED_ERROR, - (error_message = "Not authorized to perform this operation")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + NM_PERM_DENIED_ERROR, + (error_message = "Not authorized to perform this operation")); if (error) error_message = error->message; goto done; @@ -4909,17 +4909,17 @@ prop_set_auth_done_cb (NMAuthChain *chain, object = NM_EXPORTED_OBJECT (nm_bus_manager_get_registered_object (priv->dbus_mgr, g_dbus_message_get_path (pfd->message))); if (!object) { - reply = g_dbus_message_new_method_error (pfd->message, - "org.freedesktop.DBus.Error.UnknownObject", - (error_message = "Object doesn't exist.")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + "org.freedesktop.DBus.Error.UnknownObject", + (error_message = "Object doesn't exist.")); goto done; } /* do some extra type checking... */ if (!nm_exported_object_get_interface_by_type (object, pfd->interface_type)) { - reply = g_dbus_message_new_method_error (pfd->message, - "org.freedesktop.DBus.Error.InvalidArgs", - (error_message = "Object is of unexpected type.")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + "org.freedesktop.DBus.Error.InvalidArgs", + (error_message = "Object is of unexpected type.")); goto done; } @@ -4932,9 +4932,9 @@ prop_set_auth_done_cb (NMAuthChain *chain, global_dns = nm_config_data_get_global_dns_config (nm_config_get_data (priv->config)); if (global_dns && !nm_global_dns_config_is_internal (global_dns)) { - reply = g_dbus_message_new_method_error (pfd->message, - NM_PERM_DENIED_ERROR, - (error_message = "Global DNS configuration already set via configuration file")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + NM_PERM_DENIED_ERROR, + (error_message = "Global DNS configuration already set via configuration file")); goto done; } /* ... but set the property on the @object itself. It would be correct to set the property @@ -4976,18 +4976,18 @@ do_set_property_check (gpointer user_data) pfd->subject = nm_auth_subject_new_unix_process_from_message (pfd->connection, pfd->message); if (!pfd->subject) { - reply = g_dbus_message_new_method_error (pfd->message, - NM_PERM_DENIED_ERROR, - (error_message = "Could not determine request UID.")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + NM_PERM_DENIED_ERROR, + (error_message = "Could not determine request UID.")); goto out; } /* Validate the user request */ chain = nm_auth_chain_new_subject (pfd->subject, NULL, prop_set_auth_done_cb, pfd); if (!chain) { - reply = g_dbus_message_new_method_error (pfd->message, - NM_PERM_DENIED_ERROR, - (error_message = "Could not authenticate request.")); + reply = g_dbus_message_new_method_error_literal (pfd->message, + NM_PERM_DENIED_ERROR, + (error_message = "Could not authenticate request.")); goto out; }