[Openvas-commits] r5412 - in trunk/openvas-scanner: . openvassd
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Oct 7 00:51:07 CEST 2009
Author: timb
Date: 2009-10-07 00:51:07 +0200 (Wed, 07 Oct 2009)
New Revision: 5412
Modified:
trunk/openvas-scanner/ChangeLog
trunk/openvas-scanner/openvassd/utils.c
Log:
Fixed memory leak, typos and resource leak. Also added todo for TOCTOU race condition on temp_file_name() (details sent to openvas-devel@)
Modified: trunk/openvas-scanner/ChangeLog
===================================================================
--- trunk/openvas-scanner/ChangeLog 2009-10-06 22:46:52 UTC (rev 5411)
+++ trunk/openvas-scanner/ChangeLog 2009-10-06 22:51:07 UTC (rev 5412)
@@ -1,3 +1,9 @@
+2009-10-06 Tim Brown <timb at openvas.org>
+
+ * openvassd/utils.c: Fixed memory leak, typos and resource leak. Also added
+ todo for TOCTOU race condition on temp_file_name() (details sent to
+ openvas-devel@).
+
2009-10-06 Michael Wiegand <michael.wiegand at intevation.de>
Post-release version bump.
Modified: trunk/openvas-scanner/openvassd/utils.c
===================================================================
--- trunk/openvas-scanner/openvassd/utils.c 2009-10-06 22:46:52 UTC (rev 5411)
+++ trunk/openvas-scanner/openvassd/utils.c 2009-10-06 22:51:07 UTC (rev 5412)
@@ -330,8 +330,9 @@
f = fopen(fname, "w");
if(!f)
{
-fprintf(stderr, "'%s'\n", fname);
+ fprintf(stderr, "'%s'\n", fname);
perror("create_pid_file() : open ");
+ free(fname);
return;
}
fprintf(f, "%d\n", getpid());
@@ -356,7 +357,7 @@
* This function ensures that this name is not taken
* already.
*/
-/** @todo consider using glib functions */
+/** @todo consider using glib functions, the current code is subject to a TOCTOU race condition */
char*
temp_file_name()
{
@@ -365,7 +366,7 @@
do {
if(fd > 0){
if(close(fd) < 0)
- perror("close ");
+ perror("close");
}
sprintf(ret, "%s/tmp", OPENVASSD_STATEDIR);
mkdir(ret, 0700);
@@ -373,6 +374,8 @@
fd = open(ret, O_RDONLY);
}
while (fd >= 0);
+ if(close(fd) < 0)
+ perror("close");
return ret;
}
More information about the Openvas-commits
mailing list