From 2aa2b6390753639902e353f2711fefa940eb5fd3 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Mon, 12 Oct 2015 16:11:00 -0700 Subject: [PATCH] eina: fix potential security issue. This also follow the behavior of eina_file_mkstemp. Signed-off-by: Cedric BAIL --- src/lib/eina/eina_util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/eina/eina_util.c b/src/lib/eina/eina_util.c index 886fe3b52e..b1d05aeba8 100644 --- a/src/lib/eina/eina_util.c +++ b/src/lib/eina/eina_util.c @@ -85,8 +85,13 @@ eina_environment_tmp_get(void) return tmp; #else - tmp = getenv("TMPDIR"); - if (!tmp) tmp = getenv("XDG_RUNTIME_DIR"); +# if defined(HAVE_GETUID) && defined(HAVE_GETEUID) + if (getuid() == geteuid()) +# endif + { + tmp = getenv("TMPDIR"); + if (!tmp) tmp = getenv("XDG_RUNTIME_DIR"); + } if (!tmp) tmp = "/tmp"; return tmp;