X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frrd_restore.c;h=e24cc8e990d2ac4cf8f466241555c5d26f7a8db4;hb=de21789482fc7a7faf4a203e8f8d960cc8f7fb4a;hp=088193c60052286eff17fb2547833700c74a00f6;hpb=a278779cdf2ded56b89fc404d6914bff7ad7dcbd;p=rrdtool.git diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 088193c..e24cc8e 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -1,11 +1,12 @@ /***************************************************************************** - * RRDtool 1.0.33 Copyright Tobias Oetiker, 1997 - 2000 + * RRDtool 1.1.x Copyright Tobias Oetiker, 1997 - 2002 ***************************************************************************** * rrd_restore.c creates new rrd from data dumped by rrd_dump.c *****************************************************************************/ #include "rrd_tool.h" #include "rrd_rpncalc.h" +#include /* Prototypes */ @@ -406,9 +407,12 @@ rrd_write(char *file_name, rrd_t *rrd) if (strcmp("-",file_name)==0){ *rrd_file= *stdout; } else { - if ((rrd_file = fopen(file_name,"wb")) == NULL ) { + int fd = open(file_name,O_RDWR|O_CREAT|O_EXCL,0666); + if (fd == -1 || (rrd_file = fdopen(fd,"wb")) == NULL) { rrd_set_error("creating '%s': %s",file_name,strerror(errno)); rrd_free(rrd); + if (fd != -1) + close(fd); return(-1); } }