e_comp_wl_input: changed a code for creation of temp file to have secure permissions 97/206197/1
authorGwanglim Lee <gl77.lee@samsung.com>
Wed, 15 May 2019 05:29:16 +0000 (14:29 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Wed, 15 May 2019 05:29:16 +0000 (14:29 +0900)
Change-Id: I4a74305c1884778b1ddcf6377e01e5ff4b4ca03b

src/bin/e_comp_wl_input.c

index fc2a9b1f2a6e5c22cdf4cb9c0821e25ee91030cd..d2fe38d36bb281edfb9836f30ca3500f7dea85fb 100644 (file)
@@ -413,6 +413,7 @@ _e_comp_wl_input_keymap_fd_get(off_t size)
    char *path;
    char tmp[PATH_MAX] = {0, };
    long flags;
+   mode_t old_umask;
 
    blen = sizeof(tmp) - 20;
 
@@ -432,10 +433,11 @@ _e_comp_wl_input_keymap_fd_get(off_t size)
         return -1;
      }
 
-   if ((fd = mkstemp(tmp)) < 0)
-     {
-        return -1;
-     }
+   old_umask = umask(S_IRWXG|S_IRWXO);
+   fd = mkstemp(tmp);
+   umask(old_umask);
+
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(fd >= 0, -1);
 
    flags = fcntl(fd, F_GETFD);
    if (flags < 0)