summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/Makefile.am2
-rw-r--r--libglusterfs/src/common-utils.c16
-rw-r--r--libglusterfs/src/compat.h2
3 files changed, 13 insertions, 7 deletions
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index 92521cc44d1..a910d8e8a53 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -31,7 +31,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
circ-buff.c event-history.c gidcache.c ctx.c client_t.c event-poll.c \
event-epoll.c syncop-utils.c cluster-syncop.c refcount.c \
$(CONTRIBDIR)/libgen/basename_r.c \
- $(CONTRIBDIR)/libgen/dirname_r.c $(CONTRIBDIR)/stdlib/gf_mkostemp.c \
+ $(CONTRIBDIR)/libgen/dirname_r.c \
strfd.c parse-utils.c $(CONTRIBDIR)/mount/mntent.c \
$(CONTRIBDIR)/libexecinfo/execinfo.c quota-common-utils.c rot-buffs.c \
$(CONTRIBDIR)/timer-wheel/timer-wheel.c \
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;
}
diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h
index 0c56fcc5cb9..e0ffe73926a 100644
--- a/libglusterfs/src/compat.h
+++ b/libglusterfs/src/compat.h
@@ -451,8 +451,6 @@ char *dirname_r(char *path);
#define dirname(path) dirname_r(path)
#endif /* THREAD_UNSAFE_DIRNAME */
-int gf_mkostemp (char *tmpl, int suffixlen, int flags);
-
#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
/* Linux, Solaris, Cygwin */
#define ST_ATIM_SEC(stbuf) ((stbuf)->st_atim.tv_sec)