svn: 2055
@@ -73,6 +73,7 @@ bin_checksum(const char *fname, int todo)
}
fclose(f);
+ f = NULL;
MD5_Final(md5out, &ctx);
strlcpy(hash, btoh(md5out, MD5_DIGEST_LENGTH), sizeof(hash));
OPENSSL_cleanse(&ctx, sizeof(ctx));
@@ -176,7 +177,8 @@ bin_checksum(const char *fname, int todo)
- fclose(newbin->f);
+ newbin->my_close();
if (size != newpos) {
delete newbin;
@@ -269,6 +269,8 @@ confedit()
if (conf.bots && conf.bots->pid)
localhub_pid = conf.bots->pid;
+ tmpconf.my_close();
+
readconf((const char *) tmpconf.file, 0); /* read cleartext conf tmp into &settings */
fix_tilde(&conf.binpath);
unlink(tmpconf.file);
@@ -194,13 +194,21 @@ error:
// fatal("Cannot create temporary file!", 0);
-Tempfile::~Tempfile()
+void Tempfile::my_close()
{
- unlink(file);
- if (f)
+ if (f) {
- else
+ } else if (fd >= 0) {
close(fd);
+ fd = -1;
+ }
+}
+Tempfile::~Tempfile()
+{
+ unlink(file);
+ my_close();
delete[] file;
@@ -24,6 +24,7 @@ class Tempfile
public:
Tempfile(); //constructor
Tempfile(const char *prefix); //constructor with file prefix
+ void Tempfile::my_close();
~Tempfile(); //destructor
bool error; //exceptions are lame.