aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_file/ecore_file.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-04-18 17:27:21 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-04-18 17:30:50 +0900
commitc65782b15c0af7c25c5506cdf79cbbfa39604fec (patch)
tree8ca70b6bac01472abd06086e7798bd68828e491f /src/lib/ecore_file/ecore_file.c
parentgenlist - fix coverity complaint about null check (diff)
downloadefl-c65782b15c0af7c25c5506cdf79cbbfa39604fec.tar.gz
ecore file - use eina_file_mkstmp to solve umask complaint
this fixes coverity CID 1039614
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_file/ecore_file.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/ecore_file/ecore_file.c b/src/lib/ecore_file/ecore_file.c
index 6e341ea640..f5c15b6e60 100644
--- a/src/lib/ecore_file/ecore_file.c
+++ b/src/lib/ecore_file/ecore_file.c
@@ -474,6 +474,7 @@ ecore_file_mv(const char *src, const char *dst)
if (is_reg)
{
char *dir;
+ Eina_Tmpstr *tmpstr = NULL;
dir = ecore_file_dir_get(dst);
// Since we can't directly rename, try to
@@ -482,29 +483,40 @@ ecore_file_mv(const char *src, const char *dst)
snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX",
dir, ecore_file_file_get(dst));
free(dir);
- fd = mkstemp(buf);
+ fd = eina_file_mkstemp(buf, &tmpstr);
if (fd < 0) goto FAIL;
close(fd);
// Copy to temp file
- if (!ecore_file_cp(src, buf))
- goto FAIL;
+ if (!ecore_file_cp(src, tmpstr))
+ {
+ eina_tmpstr_del(tmpstr);
+ goto FAIL;
+ }
// Set file permissions of temp file to match src
- if (chmod(buf, mode) == -1) goto FAIL;
+ if (chmod(buf, mode) == -1)
+ {
+ eina_tmpstr_del(tmpstr);
+ goto FAIL;
+ }
// Try to atomically move temp file to dst
- if (rename(buf, dst))
+ if (rename(tmpstr, dst))
{
// If we still cannot atomically move
// do a normal copy and hope for the best.
- if (!ecore_file_cp(buf, dst))
- goto FAIL;
+ if (!ecore_file_cp(tmpstr, dst))
+ {
+ eina_tmpstr_del(tmpstr);
+ goto FAIL;
+ }
}
// Delete temporary file and src
- ecore_file_unlink(buf);
+ ecore_file_unlink(tmpstr);
ecore_file_unlink(src);
+ eina_tmpstr_del(tmpstr);
goto PASS;
}
}