summaryrefslogtreecommitdiff
path: root/daemon/gvfsjobopenforread.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-04-03 15:08:20 +0200
committerTomas Bzatek <tbzatek@redhat.com>2013-04-03 15:08:20 +0200
commit94f8380381c46b1512712be1192894dd9a9e12f0 (patch)
tree31aef7a1643248ded3e74563eda3a1e8872e31a2 /daemon/gvfsjobopenforread.c
parent421ce4a6b4526047fde9d8d039a66b520eb09f3f (diff)
downloadgvfs-94f8380381c46b1512712be1192894dd9a9e12f0.tar.gz
gvfschannel: Return proper error if we're out of free fds
In case of too many open files within the process the g_vfs_channel_init() call fails on socketpair and subsequent g_vfs_channel_steal_remote_fd() call returns -1 for the fd. Then g_unix_fd_list_append() hits the assert and doesn't set an error we're dereferencing afterwards. This patch doesn't solve the lack of free fds situation and since glib heavily depends on it it would fail somewhere else. We're just fixing the segfault and returning nicer error. Based on a fix suggested by Stephen M. Webb https://bugzilla.gnome.org/show_bug.cgi?id=696713
Diffstat (limited to 'daemon/gvfsjobopenforread.c')
-rw-r--r--daemon/gvfsjobopenforread.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/daemon/gvfsjobopenforread.c b/daemon/gvfsjobopenforread.c
index 32eaf59e..d9781365 100644
--- a/daemon/gvfsjobopenforread.c
+++ b/daemon/gvfsjobopenforread.c
@@ -174,7 +174,17 @@ create_reply (GVfsJob *job,
open_job->pid);
remote_fd = g_vfs_channel_steal_remote_fd (G_VFS_CHANNEL (channel));
-
+ if (remote_fd < 0)
+ {
+ /* expecting we're out of fds when remote_fd == -1 */
+ g_dbus_method_invocation_return_error_literal (invocation,
+ G_IO_ERROR,
+ G_IO_ERROR_TOO_MANY_OPEN_FILES,
+ _("Couldn't get stream file descriptor"));
+ g_object_unref (channel);
+ return;
+ }
+
fd_list = g_unix_fd_list_new ();
error = NULL;
fd_id = g_unix_fd_list_append (fd_list, remote_fd, &error);