e_comp_wl_rsm: make sure temp file is created with secure permissions. 14/198014/2
authorGwanglim Lee <gl77.lee@samsung.com>
Fri, 18 Jan 2019 00:21:10 +0000 (09:21 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 28 Jan 2019 07:43:08 +0000 (07:43 +0000)
Change-Id: I1bc7262df16c982283e170282d7be800e2a3e430

src/bin/e_comp_wl_rsm.c

index de9891e73ac373d20f0b8a1c5a1deedf0dcaa435..5f0eb2abc14b7d5414ee4bbcdf7d2fece85f8017 100644 (file)
@@ -3378,9 +3378,10 @@ _e_comp_wl_remote_surface_dummy_fd_get(void)
 {
    int fd = 0, blen = 0, len = 0;
    char *path;
-   char tmp[PATH_MAX];
+   char buf[PATH_MAX];
+   Eina_Tmpstr *tmpstr = NULL;
 
-   blen = sizeof(tmp) - 1;
+   blen = sizeof(buf) - 1;
 
    path = e_util_env_get("XDG_RUNTIME_DIR");
    if (!path) return -1;
@@ -3388,8 +3389,8 @@ _e_comp_wl_remote_surface_dummy_fd_get(void)
    len = strlen(path);
    if (len < blen)
      {
-        strncpy(tmp, path, len + 1);
-        strncat(tmp, "/enlightenment_rsm_dummy_fdXXXXXX", 34);
+        strncpy(buf, path, len + 1);
+        strncat(buf, "/enlightenment_rsm_dummy_fdXXXXXX", 34);
         E_FREE(path);
      }
    else
@@ -3398,10 +3399,11 @@ _e_comp_wl_remote_surface_dummy_fd_get(void)
         return -1;
      }
 
-   if ((fd = mkstemp(tmp)) < 0)
+   if ((fd = eina_file_mkstemp(buf, &tmpstr)) < 0)
      return -1;
 
-   unlink(tmp);
+   ecore_file_unlink(tmpstr);
+   eina_tmpstr_del(tmpstr);
 
    return fd;
 }