[evince/wip/chpe/issue-988: 8/8] libdocument: Fix decompression



commit 443dfeee7ed4d4a6c4161588ea4d0d0ff362c967
Author: Christian Persch <chpe src gnome org>
Date:   Tue Sep 25 20:37:06 2018 +0200

    libdocument: Fix decompression
    
    Unset the CLOEXEC flag in the child setup function
    when spawning the decompressor.
    
    https://gitlab.gnome.org/GNOME/evince/issues/988

 libdocument/ev-file-helpers.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index 07f8f2c7..ade0bf29 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -595,6 +595,19 @@ static const char *compressor_cmds[] = {
 #define N_ARGS      4
 #define BUFFER_SIZE 1024
 
+static void
+compression_child_setup_cb (gpointer fd_ptr)
+{
+        int fd = GPOINTER_TO_INT (fd_ptr);
+        int flags;
+
+        flags = fcntl (fd, F_GETFD);
+        if (flags >= 0 && (flags & FD_CLOEXEC)) {
+                flags &= ~FD_CLOEXEC;
+                fcntl (fd, F_SETFD, flags);
+        }
+}
+
 static gchar *
 compression_run (const gchar       *uri,
                 EvCompressionType  type,
@@ -642,7 +655,8 @@ compression_run (const gchar       *uri,
 
        if (g_spawn_async_with_pipes (NULL, argv, NULL,
                                      G_SPAWN_STDERR_TO_DEV_NULL,
-                                     NULL, NULL, NULL,
+                                      compression_child_setup_cb, GINT_TO_POINTER (fd),
+                                      NULL,
                                      NULL, &pout, NULL, &err)) {
                GIOChannel *in, *out;
                gchar buf[BUFFER_SIZE];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]