public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: RHEL5 - ccs_tool: randomize temporary file
@ 2009-05-06 9:14 Christine Caulfield
0 siblings, 0 replies; only message in thread
From: Christine Caulfield @ 2009-05-06 9:14 UTC (permalink / raw)
To: cluster-cvs-relay
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-06 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-06 9:14 cluster: RHEL5 - ccs_tool: randomize temporary file Christine Caulfield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).