[Openvas-commits] r6099 - in trunk/openvas-libraries: . misc
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Dec 9 01:34:34 CET 2009
Author: timb
Date: 2009-12-09 01:34:32 +0100 (Wed, 09 Dec 2009)
New Revision: 6099
Modified:
trunk/openvas-libraries/ChangeLog
trunk/openvas-libraries/misc/network.c
Log:
Fixed a potential resource leak
Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog 2009-12-08 21:02:24 UTC (rev 6098)
+++ trunk/openvas-libraries/ChangeLog 2009-12-09 00:34:32 UTC (rev 6099)
@@ -1,3 +1,7 @@
+2009-12-09 Tim Brown <timb at openvas.org>
+
+ * misc/network.c: Fixed a potential resource leak.
+
2009-12-07 Felix Wolfsteller <felix.wolfsteller at intevation.de>
* misc/pcap.c: Cosmetics and docs.
Modified: trunk/openvas-libraries/misc/network.c
===================================================================
--- trunk/openvas-libraries/misc/network.c 2009-12-08 21:02:24 UTC (rev 6098)
+++ trunk/openvas-libraries/misc/network.c 2009-12-09 00:34:32 UTC (rev 6099)
@@ -582,7 +582,6 @@
/** helper function copied from cli.c from GnuTLS
Reads a file into a gnutls_datum
- @todo Fix the resource leak of FILE *f
**/
static gnutls_datum
load_file (const char *file)
@@ -592,18 +591,20 @@
long filelen;
void *ptr;
- if (!(f = fopen(file, "r"))
- || fseek(f, 0, SEEK_END) != 0
+ if (!(f = fopen(file, "r"))) return loaded_file;
+ if (fseek(f, 0, SEEK_END) != 0
|| (filelen = ftell(f)) < 0
|| fseek(f, 0, SEEK_SET) != 0
|| !(ptr = emalloc((size_t) filelen))
|| fread(ptr, 1, (size_t) filelen, f) < (size_t) filelen)
{
+ fclose(f);
return loaded_file;
}
loaded_file.data = ptr;
loaded_file.size = (unsigned int) filelen;
+ fclose(f);
return loaded_file;
}
More information about the Openvas-commits
mailing list