eina: And guard the right function with umask
authorSebastian Dransfeld <sebastian.dransfeld@sintef.no>
Wed, 16 Oct 2013 02:56:51 +0000 (04:56 +0200)
committerSebastian Dransfeld <sebastian.dransfeld@sintef.no>
Wed, 16 Oct 2013 02:56:51 +0000 (04:56 +0200)
Thanks Cedric.

src/lib/eina/eina_file_common.c

index 9a222c2..3a68345 100644 (file)
@@ -878,15 +878,16 @@ eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
    tmpdir = (char *)evil_tmpdir_get();
 #endif /* ! HAVE_EVIL */
 
+   snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
+
    /* 
     * Make sure temp file is created with secure permissions,
     * http://man7.org/linux/man-pages/man3/mkstemp.3.html#NOTES
     */
    old_umask = umask(0077);
-   snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
+   fd = mkstemp(buffer);
    umask(old_umask);
 
-   fd = mkstemp(buffer);
    if (path) *path = eina_tmpstr_add(buffer);
    if (fd < 0)
      return -1;