Blame SOURCES/guile-1.8.8-cve-2016-8605.patch

43e42a
commit 245608911698adb3472803856019bdd5670b6614
43e42a
Author: Ludovic Courtès <ludo@gnu.org>
43e42a
Date:   Tue Oct 11 10:14:26 2016 +0200
43e42a
43e42a
    Remove 'umask' calls from 'mkdir'.
43e42a
    
43e42a
    Fixes <http://bugs.gnu.org/24659>.
43e42a
    
43e42a
    * libguile/filesys.c (SCM_DEFINE): Remove calls to 'umask' when MODE is
43e42a
    unbound; instead, use 0777 as the mode.  Update docstring to clarify
43e42a
    this.
43e42a
    * doc/ref/posix.texi (File System): Adjust accordingly.
43e42a
    * NEWS: Mention it.
43e42a
43e42a
diff --git a/libguile/filesys.c b/libguile/filesys.c
43e42a
index e6e1db5..e6e37b0 100644
43e42a
--- a/libguile/filesys.c
43e42a
+++ b/libguile/filesys.c
43e42a
@@ -1255,26 +1255,21 @@ SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0,
43e42a
 SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
43e42a
             (SCM path, SCM mode),
43e42a
 	    "Create a new directory named by @var{path}.  If @var{mode} is omitted\n"
43e42a
-	    "then the permissions of the directory file are set using the current\n"
43e42a
-	    "umask.  Otherwise they are set to the decimal value specified with\n"
43e42a
-	    "@var{mode}.  The return value is unspecified.")
43e42a
+	    "then the permissions of the directory are set to @code{#o777}\n"
43e42a
+	    "masked with the current umask (@pxref{Processes, @code{umask}}).\n"
43e42a
+	    "Otherwise they are set to the value specified with @var{mode}.\n"
43e42a
+	    "The return value is unspecified.")
43e42a
 #define FUNC_NAME s_scm_mkdir
43e42a
 {
43e42a
   int rv;
43e42a
-  mode_t mask;
43e42a
+  mode_t c_mode;
43e42a
 
43e42a
-  if (SCM_UNBNDP (mode))
43e42a
-    {
43e42a
-      mask = umask (0);
43e42a
-      umask (mask);
43e42a
-      STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
43e42a
-    }
43e42a
-  else
43e42a
-    {
43e42a
-      STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
43e42a
-    }
43e42a
+  c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode);
43e42a
+
43e42a
+  STRING_SYSCALL (path, c_path, rv = mkdir (c_path, c_mode));
43e42a
   if (rv != 0)
43e42a
     SCM_SYSERROR;
43e42a
+
43e42a
   return SCM_UNSPECIFIED;
43e42a
 }
43e42a
 #undef FUNC_NAME