cluster: RHEL5 - ccs_tool: randomize temporary file
Christine Caulfield
chrissie@fedoraproject.org
Wed May 6 09:14:00 GMT 2009
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b07fe54c617838b9d281666dee9acffbf64c1d94
Commit: b07fe54c617838b9d281666dee9acffbf64c1d94
Parent: c91d2c721a2dc1af8da48acd64849ba513a8a9fe
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Thu Oct 30 13:21:38 2008 +0100
Committer: Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Wed May 6 10:12:13 2009 +0100
ccs_tool: randomize temporary file
by using a static path to /tmp, the operation can be used to trigger
a local DoS by a normal user.
Switch to mkostemp(3).
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
ccs/ccs_tool/upgrade.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/ccs/ccs_tool/upgrade.c b/ccs/ccs_tool/upgrade.c
index f8759ae..2dc7f35 100644
--- a/ccs/ccs_tool/upgrade.c
+++ b/ccs/ccs_tool/upgrade.c
@@ -193,7 +193,7 @@ static void ccs_dh_in(ccs_dh_t *dh, char *buf){
static int upgrade_device_archive(char *location){
int error = 0;
int dev_fd=-1, tmp_fd=-1;
- char tmp_file[64];
+ char tmp_file[128];
void *buffer = NULL;
char *buffer_p;
ccs_dh_t dev_header;
@@ -231,9 +231,10 @@ static int upgrade_device_archive(char *location){
goto fail;
}
- sprintf(tmp_file, "/tmp/tmp_%d", getpid());
+ memset(tmp_file, 0, 128);
+ sprintf(tmp_file, "/tmp/ccs_tool_tmp_XXXXXX");
- tmp_fd = open(tmp_file, O_RDWR | O_CREAT |O_TRUNC, S_IRUSR|S_IWUSR);
+ tmp_fd = mkostemp(tmp_file, O_RDWR | O_CREAT |O_TRUNC);
if(tmp_fd < 0){
fprintf(stderr, "Unable to create temporary archive: %s\n", strerror(errno));
error = -errno;
More information about the Cluster-cvs
mailing list