git-svn: trunk@3489
Tomasz Kojm authored on 2008/01/09 22:47:17... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed Jan 9 14:19:15 CET 2008 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * freshclam/manager.c: under some conditions old db files were not being |
|
4 |
+ removed |
|
5 |
+ |
|
1 | 6 |
Wed Jan 9 12:29:48 CET 2008 (tk) |
2 | 7 |
--------------------------------- |
3 | 8 |
* libclamav/cvd.c: gzdopen() may not close fd |
... | ... |
@@ -941,7 +941,7 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
941 | 941 |
const struct cfgstruct *cpt; |
942 | 942 |
unsigned int nodb = 0, currver = 0, newver = 0, port = 0, i, j; |
943 | 943 |
int ret, ims = -1; |
944 |
- char *pt, cvdfile[32], localname[32], *tmpdir = NULL, *newfile, newdb[512], cwd[512]; |
|
944 |
+ char *pt, cvdfile[32], localname[32], *tmpdir = NULL, *newfile, newdb[32], cwd[512]; |
|
945 | 945 |
const char *proxy = NULL, *user = NULL, *pass = NULL, *uas = NULL; |
946 | 946 |
unsigned int flevel = cl_retflevel(), maxattempts; |
947 | 947 |
int ctimeout, rtimeout; |
... | ... |
@@ -951,7 +951,6 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
951 | 951 |
|
952 | 952 |
if(!(current = currentdb(dbname, localname))) { |
953 | 953 |
nodb = 1; |
954 |
- strcpy(localname, cvdfile); |
|
955 | 954 |
} else { |
956 | 955 |
mdat->dbflevel = current->fl; |
957 | 956 |
} |
... | ... |
@@ -1085,7 +1084,7 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
1085 | 1085 |
free(newfile); |
1086 | 1086 |
return ret; |
1087 | 1087 |
} |
1088 |
- snprintf(localname, sizeof(localname), "%s.cvd", dbname); |
|
1088 |
+ snprintf(newdb, sizeof(newdb), "%s.cvd", dbname); |
|
1089 | 1089 |
|
1090 | 1090 |
} else { |
1091 | 1091 |
ret = 0; |
... | ... |
@@ -1115,7 +1114,7 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
1115 | 1115 |
free(newfile); |
1116 | 1116 |
return ret; |
1117 | 1117 |
} |
1118 |
- snprintf(localname, sizeof(localname), "%s.cvd", dbname); |
|
1118 |
+ snprintf(newdb, sizeof(newdb), "%s.cvd", dbname); |
|
1119 | 1119 |
} else { |
1120 | 1120 |
if(buildcld(tmpdir, dbname, newfile, cfgopt(copt, "CompressLocalDatabase")->enabled) == -1) { |
1121 | 1121 |
logg("!Can't create local database\n"); |
... | ... |
@@ -1124,31 +1123,26 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
1124 | 1124 |
free(newfile); |
1125 | 1125 |
return 70; /* FIXME */ |
1126 | 1126 |
} |
1127 |
- snprintf(localname, sizeof(localname), "%s.cld", dbname); |
|
1127 |
+ snprintf(newdb, sizeof(newdb), "%s.cld", dbname); |
|
1128 | 1128 |
cli_rmdirs(tmpdir); |
1129 | 1129 |
free(tmpdir); |
1130 | 1130 |
} |
1131 | 1131 |
} |
1132 | 1132 |
|
1133 | 1133 |
if(!(current = cl_cvdhead(newfile))) { |
1134 |
- logg("!Can't parse new database %s\n",newfile); |
|
1134 |
+ logg("!Can't parse new database %s\n", newfile); |
|
1135 | 1135 |
unlink(newfile); |
1136 | 1136 |
free(newfile); |
1137 | 1137 |
return 55; /* FIXME */ |
1138 | 1138 |
} |
1139 | 1139 |
|
1140 |
- if(strlen(newfile) > 507) { /* shouldn't happen */ |
|
1141 |
- logg("!newfile: File name too long\n"); |
|
1140 |
+ if(!nodb && !access(localname, R_OK) && unlink(localname)) { |
|
1141 |
+ logg("!Can't unlink %s. Please fix it and try again.\n", localname); |
|
1142 | 1142 |
unlink(newfile); |
1143 | 1143 |
free(newfile); |
1144 |
- return 70; /* FIXME */ |
|
1144 |
+ return 53; |
|
1145 | 1145 |
} |
1146 | 1146 |
|
1147 |
- if(strstr(localname, ".cld")) |
|
1148 |
- snprintf(newdb, sizeof(newdb), "%s.cld", newfile); |
|
1149 |
- else |
|
1150 |
- snprintf(newdb, sizeof(newdb), "%s.cvd", newfile); |
|
1151 |
- |
|
1152 | 1147 |
if(rename(newfile, newdb) == -1) { |
1153 | 1148 |
logg("!Can't rename %s to %s\n", newfile, newdb); |
1154 | 1149 |
unlink(newfile); |
... | ... |
@@ -1157,25 +1151,7 @@ static int updatedb(const char *dbname, const char *hostname, char *ip, int *sig |
1157 | 1157 |
} |
1158 | 1158 |
free(newfile); |
1159 | 1159 |
|
1160 |
- if(!nodb && !access(cvdfile, R_OK) && unlink(cvdfile)) { |
|
1161 |
- logg("!Can't unlink %s. Please fix it and try again.\n", cvdfile); |
|
1162 |
- unlink(newdb); |
|
1163 |
- return 53; |
|
1164 |
- } |
|
1165 |
- |
|
1166 |
- if(!nodb && strcmp(cvdfile, localname) && !access(localname, R_OK) && unlink(localname)) { |
|
1167 |
- logg("!Can't unlink %s. Please fix it and try again.\n", localname); |
|
1168 |
- unlink(newdb); |
|
1169 |
- return 53; |
|
1170 |
- } |
|
1171 |
- |
|
1172 |
- if(rename(newdb, localname) == -1) { |
|
1173 |
- logg("!Can't rename %s to %s\n", newdb, localname); |
|
1174 |
- unlink(newdb); |
|
1175 |
- return 57; |
|
1176 |
- } |
|
1177 |
- |
|
1178 |
- logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", localname, current->version, current->sigs, current->fl, current->builder); |
|
1160 |
+ logg("%s updated (version: %d, sigs: %d, f-level: %d, builder: %s)\n", newdb, current->version, current->sigs, current->fl, current->builder); |
|
1179 | 1161 |
|
1180 | 1162 |
if(flevel < current->fl) { |
1181 | 1163 |
logg("^Your ClamAV installation is OUTDATED!\n"); |