This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
STABLE2 - gfs2: randomize file for savemeta operations even more
- From: "Fabio M. Di Nitto" <fabbione at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Thu, 30 Oct 2008 08:57:27 +0000 (UTC)
- Subject: STABLE2 - gfs2: randomize file for savemeta operations even more
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=58a054bff87c5e6afa21bdafd81ad5b95360e67b
Commit: 58a054bff87c5e6afa21bdafd81ad5b95360e67b
Parent: df5592b2b25b586b06465ef8b756e561fd47b46e
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Thu Oct 30 09:54:52 2008 +0100
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Thu Oct 30 09:57:04 2008 +0100
gfs2: randomize file for savemeta operations even more
15f9eb851b8924271095b159b2d077a9a0595cd5 didn't introduce enough
security.
Switch to mkstemp(3) and cleanup unrequired code as a consequence.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
gfs2/edit/savemeta.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4ee1e5d..901d28c 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -24,7 +24,7 @@
#include "libgfs2.h"
#define BUFSIZE (4096)
-#define DFT_SAVE_FILE "/tmp/gfsmeta"
+#define DFT_SAVE_FILE "/tmp/gfsmeta.XXXXXX"
#define MAX_JOURNALS_SAVED 256
struct saved_metablock {
@@ -728,13 +728,13 @@ void savemeta(char *out_fn, int saveoption)
sbd.md.journals = 1;
if (!out_fn) {
- out_fn = malloc(PATH_MAX);
+ out_fn = strdup(DFT_SAVE_FILE);
if (!out_fn)
die("Can't allocate memory for the operation.\n");
- memset(out_fn, 0, PATH_MAX);
- sprintf(out_fn, DFT_SAVE_FILE ".%d", getpid());
- }
- out_fd = open(out_fn, O_RDWR | O_CREAT, 0644);
+ out_fd = mkstemp(out_fn);
+ } else
+ out_fd = open(out_fn, O_RDWR | O_CREAT, 0644);
+
if (out_fd < 0)
die("Can't open %s: %s\n", out_fn, strerror(errno));