summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-08-29 15:36:57 +0200
committerOndrej Holy <oholy@redhat.com>2018-09-04 07:08:24 +0000
commitd1ab5870e828df259897598298c2ca66b587426a (patch)
treedf0731a8838bfd123cc96ce66d31ec26db8da5b4
parent4462d3e6ed4801504889d147cb5cc460e1b21dc4 (diff)
downloadgvfs-d1ab5870e828df259897598298c2ca66b587426a.tar.gz
backend: Prevent usage of NULL
g_dbus_connection_get_peer_credentials may fail in some cases, see the documentation, and thus we have to check the return value before use in order to prevent warnings like the following: g_credentials_get_unix_pid: assertion 'G_IS_CREDENTIALS (credentials)' failed Print simply -1 if pid can't be obtained this way.
-rw-r--r--daemon/gvfsbackend.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/daemon/gvfsbackend.c b/daemon/gvfsbackend.c
index 673070fa..4fd3455c 100644
--- a/daemon/gvfsbackend.c
+++ b/daemon/gvfsbackend.c
@@ -609,14 +609,17 @@ g_vfs_backend_invocation_first_handler (GVfsDBusMount *object,
{
GDBusConnection *connection;
GCredentials *credentials;
+ pid_t pid = -1;
connection = g_dbus_method_invocation_get_connection (invocation);
credentials = g_dbus_connection_get_peer_credentials (connection);
+ if (credentials)
+ pid = g_credentials_get_unix_pid (credentials, NULL);
- g_debug ("backend_dbus_handler %s:%s (pid=%u)\n",
+ g_debug ("backend_dbus_handler %s:%s (pid=%ld)\n",
g_dbus_method_invocation_get_interface_name (invocation),
g_dbus_method_invocation_get_method_name (invocation),
- g_credentials_get_unix_pid (credentials, NULL));
+ (long)pid);
if (backend->priv->block_requests)
{