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



commit f6214ddcbd608014e6d2ca4252ebd50c2d709c4d
Author: Christian Persch <chpe src gnome org>
Date:   Tue Sep 25 20:34:04 2018 +0200

    libdocument: Fix ev_mkstemp
    
    Add missing O_RDWR flag.
    
    https://gitlab.gnome.org/GNOME/evince/issues/988

 libdocument/ev-file-helpers.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/libdocument/ev-file-helpers.c b/libdocument/ev-file-helpers.c
index c9de2f83..07f8f2c7 100644
--- a/libdocument/ev-file-helpers.c
+++ b/libdocument/ev-file-helpers.c
@@ -20,6 +20,7 @@
 #include <config.h>
 
 #include <stdlib.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <string.h>
@@ -34,6 +35,10 @@
 
 static gchar *tmp_dir = NULL;
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 /*
  * ev_dir_ensure_exists:
  * @dir: the directory name
@@ -139,7 +144,7 @@ ev_mkstemp (const char  *tmpl,
               return -1;
 
         name = g_build_filename (tmp, tmpl, NULL);
-        fd = g_mkstemp_full (name, O_CLOEXEC, 0600);
+        fd = g_mkstemp_full (name, O_RDWR | O_BINARY | O_CLOEXEC, 0600);
 
         if (fd == -1) {
                int errsv = errno;


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