eina: And guard the right function with umask

Thanks Cedric.
This commit is contained in:
Sebastian Dransfeld 2013-10-16 04:56:51 +02:00
parent bd5a5e7fce
commit 0b26b1bd89
1 changed files with 3 additions and 2 deletions

View 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;