[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Tomasz Kojm
tkojm at clamav.net
Sun Apr 4 00:59:25 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 99ca7f53f8593ac25c952fd5b9744a1648b3dc3c
Author: Tomasz Kojm <tkojm at clamav.net>
Date: Tue Aug 4 15:14:22 2009 +0200
freshclam, libclamav: work around possible race condition during db updates (bb#1624)
diff --git a/ChangeLog b/ChangeLog
index 66a68c7..76e0225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Aug 4 15:10:12 CEST 2009 (tk)
+----------------------------------
+ * freshclam, libclamav: work around possible race condition during
+ db updates (bb#1624)
+
Mon Aug 3 15:22:42 CEST 2009 (tk)
----------------------------------
* freshclam/manager.c: fix confusing error message (bb#1648)
diff --git a/freshclam/manager.c b/freshclam/manager.c
index d89f675..bc06abc 100644
--- a/freshclam/manager.c
+++ b/freshclam/manager.c
@@ -1683,18 +1683,12 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
return 55; /* FIXME */
}
- if(!nodb && !access(localname, R_OK) && unlink(localname)) {
- logg("!Can't unlink %s. Please fix it and try again.\n", localname);
- unlink(newfile);
- free(newfile);
- return 53;
- }
-
#ifdef C_WINDOWS
if(!access(newdb, R_OK) && unlink(newdb)) {
logg("!Can't unlink %s. Please fix the problem manually and try again.\n", newdb);
unlink(newfile);
free(newfile);
+ cl_cvdfree(current);
return 53;
}
#endif
@@ -1703,10 +1697,15 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig
logg("!Can't rename %s to %s: %s\n", newfile, newdb, strerror(errno));
unlink(newfile);
free(newfile);
+ cl_cvdfree(current);
return 57;
}
free(newfile);
+ if(!nodb && !access(localname, R_OK) && strcmp(newdb, localname))
+ if(unlink(localname))
+ logg("^Can't unlink the old database file %s. Please remove it manually.\n", localname);
+
logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", newdb, current->version, current->sigs, current->fl, current->builder);
if(flevel < current->fl) {
diff --git a/libclamav/clamav.h b/libclamav/clamav.h
index 3683dfd..98e779c 100644
--- a/libclamav/clamav.h
+++ b/libclamav/clamav.h
@@ -79,6 +79,7 @@ typedef enum {
#define CL_DB_PUA_INCLUDE 0x100
#define CL_DB_PUA_EXCLUDE 0x200
#define CL_DB_COMPILED 0x400 /* internal */
+#define CL_DB_DIRECTORY 0x800 /* internal */
/* recommended db settings */
#define CL_DB_STDOPT (CL_DB_PHISHING | CL_DB_PHISHING_URLS | CL_DB_CVDNOTMP)
diff --git a/libclamav/readdb.c b/libclamav/readdb.c
index ae5e64b..bd5cec9 100644
--- a/libclamav/readdb.c
+++ b/libclamav/readdb.c
@@ -39,6 +39,7 @@
#endif
#include <fcntl.h>
#include <zlib.h>
+#include <errno.h>
#include "clamav.h"
#include "cvd.h"
@@ -1525,6 +1526,14 @@ int cli_load(const char *filename, struct cl_engine *engine, unsigned int *signo
if(!dbio && (fs = fopen(filename, "rb")) == NULL) {
+ if(options & CL_DB_DIRECTORY) { /* bb#1624 */
+ if(access(filename, R_OK)) {
+ if(errno == ENOENT) {
+ cli_dbgmsg("Detected race condition, ignoring old file %s\n", filename);
+ return CL_SUCCESS;
+ }
+ }
+ }
cli_errmsg("cli_load(): Can't open file %s\n", filename);
return CL_EOPEN;
}
@@ -1769,7 +1778,7 @@ int cl_load(const char *path, struct cl_engine *engine, unsigned int *signo, uns
break;
case S_IFDIR:
- ret = cli_loaddbdir(path, engine, signo, dboptions);
+ ret = cli_loaddbdir(path, engine, signo, dboptions | CL_DB_DIRECTORY);
break;
default:
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list