diff options
author | ShyamsundarR <srangana@redhat.com> | 2018-07-30 20:16:21 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-08-16 06:10:44 +0000 |
commit | 9297e1950f76270e99c76970f57810e01e305a3b (patch) | |
tree | 9b1cf851e6d44341b0c391fa67a717ad0cb17235 /libglusterfs/src/common-utils.c | |
parent | 82e5acd6b30aabccb0a1e157dc633591c4919a3e (diff) |
contrib: Remove gf_mkostemp copied from GLibC
gf_mkostemp is borrowed from GLibC a long time back,
we now have mkostemp or mkstemp alternatives with all
distributions and versions that we care for.
As a result removing this from the contrib directory
and modifying the one instance that is still using the
same.
This is part of code cleanup as we cleaned up coverity
SECUR_TEMP errors.
Updates: bz#1193929
Change-Id: I1ad7863043cdb0845c53748f5a0522e767079130
Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r-- | libglusterfs/src/common-utils.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 543f8601ebe..374b76b0410 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4238,16 +4238,26 @@ gf_backtrace_fillframes (char *buf) size_t idx = 0; size_t pos = 0; size_t inc = 0; - char tmpl[32] = "/tmp/btXXXXXX"; + char tmpl[] = "/tmp/glfs-bt-XXXXXX"; frames = backtrace (array, GF_BACKTRACE_FRAME_COUNT); if (!frames) return -1; - fd = gf_mkostemp (tmpl, 0, O_RDWR); + /* coverity[secure_temp] mkstemp uses 0600 as the mode and is safe */ + fd = mkstemp (tmpl); if (fd == -1) return -1; + /* Calling unlink so that when the file is closed or program + * terminates the temporary file is deleted. + */ + ret = sys_unlink (tmpl); + if (ret < 0) { + gf_msg (THIS->name, GF_LOG_INFO, 0, LG_MSG_FILE_OP_FAILED, + "Unable to delete temporary file: %s", tmpl); + } + /*The most recent two frames are the calling function and * gf_backtrace_save, which we can infer.*/ @@ -4280,8 +4290,6 @@ out: if (fp) fclose (fp); - sys_unlink (tmpl); - return (idx > 0)? 0: -1; } |