forked from enlightenment/efl
ecore-evas-extn: Use eina_mkstemp in place of mkstemp
Summary: This fixes Coverity CID1039610 'calling mkstemp without securely setting umask first'. Since we have eina_mkstemp which already handles creating temporary files in the proper directory, let's use it. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
820eca333e
commit
ea77578ad6
|
@ -19,6 +19,7 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
|
||||||
char file[PATH_MAX];
|
char file[PATH_MAX];
|
||||||
mode_t mode = S_IRUSR | S_IWUSR;
|
mode_t mode = S_IRUSR | S_IWUSR;
|
||||||
int page_size;
|
int page_size;
|
||||||
|
Eina_Tmpstr *tmp;
|
||||||
|
|
||||||
page_size = eina_cpu_page_size();
|
page_size = eina_cpu_page_size();
|
||||||
|
|
||||||
|
@ -40,18 +41,7 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
|
||||||
|
|
||||||
if (b->am_owner)
|
if (b->am_owner)
|
||||||
{
|
{
|
||||||
const char *s = NULL;
|
b->lockfd = eina_file_mkstemp("ee-lock-XXXXXX", &tmp);
|
||||||
|
|
||||||
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
|
|
||||||
if (getuid() == geteuid())
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
s = getenv("XDG_RUNTIME_DIR");
|
|
||||||
if (!s) s = getenv("TMPDIR");
|
|
||||||
}
|
|
||||||
if (!s) s = "/tmp";
|
|
||||||
snprintf(file, sizeof(file), "%s/ee-lock-XXXXXX", s);
|
|
||||||
b->lockfd = mkstemp(file);
|
|
||||||
if (b->lockfd < 0) goto err;
|
if (b->lockfd < 0) goto err;
|
||||||
b->lock = eina_stringshare_add(file);
|
b->lock = eina_stringshare_add(file);
|
||||||
if (!b->lock) goto err;
|
if (!b->lock) goto err;
|
||||||
|
@ -69,6 +59,7 @@ _extnbuf_new(const char *base, int id, Eina_Bool sys, int num,
|
||||||
if (b->addr == MAP_FAILED) goto err;
|
if (b->addr == MAP_FAILED) goto err;
|
||||||
return b;
|
return b;
|
||||||
err:
|
err:
|
||||||
|
if (tmp) eina_tmpstr_del(tmp);
|
||||||
_extnbuf_free(b);
|
_extnbuf_free(b);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue