Browse code

add support for .cld files (bb#745)

git-svn: trunk@3480

Tomasz Kojm authored on 2008/01/03 21:10:53
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Jan  3 12:38:03 CET 2008 (tk)
2
+---------------------------------
3
+  * shared/misc.c, clamd/session.c: add support for .cld files (bb#745)
4
+
1 5
 Wed Jan  2 13:46:24 CET 2008 (acab)
2 6
   * libclamav/explode.c: big endian support
3 7
 
... ...
@@ -105,7 +105,6 @@ int command(int desc, const struct cl_engine *engine, const struct cl_limits *li
105 105
 	    const char *dbdir = cfgopt(copt, "DatabaseDirectory")->strarg;
106 106
 	    char *path;
107 107
 	    struct cl_cvd *daily;
108
-	    struct stat foo;
109 108
 
110 109
 
111 110
 	if(!(path = malloc(strlen(dbdir) + 30))) {
... ...
@@ -114,10 +113,10 @@ int command(int desc, const struct cl_engine *engine, const struct cl_limits *li
114 114
 	}
115 115
 
116 116
 	sprintf(path, "%s/daily.cvd", dbdir);
117
-	if(stat(path, &foo) == -1)
118
-	    sprintf(path, "%s/daily.inc/daily.info", dbdir);
117
+	if(access(path, R_OK))
118
+	    sprintf(path, "%s/daily.cld", dbdir);
119 119
 
120
-	if((daily = cl_cvdhead(path))) {
120
+	if(!access(path, R_OK) && (daily = cl_cvdhead(path))) {
121 121
 		time_t t = (time_t) daily->stime;
122 122
 
123 123
 	    pthread_mutex_lock(&ctime_mutex);
... ...
@@ -59,7 +59,6 @@ char *freshdbdir(void)
59 59
 	struct cl_cvd *d1, *d2;
60 60
 	struct cfgstruct *copt;
61 61
 	const struct cfgstruct *cpt;
62
-	struct stat foo;
63 62
 	const char *dbdir;
64 63
 	char *retdir;
65 64
 
... ...
@@ -71,13 +70,13 @@ char *freshdbdir(void)
71 71
 	    if(strcmp(dbdir, cpt->strarg)) {
72 72
 		    char *daily = (char *) malloc(strlen(cpt->strarg) + strlen(dbdir) + 30);
73 73
 		sprintf(daily, "%s/daily.cvd", cpt->strarg);
74
-		if(stat(daily, &foo) == -1)
75
-		    sprintf(daily, "%s/daily.inc/daily.info", cpt->strarg);
74
+		if(access(daily, R_OK))
75
+		    sprintf(daily, "%s/daily.cld", cpt->strarg);
76 76
 
77 77
 		if((d1 = cl_cvdhead(daily))) {
78 78
 		    sprintf(daily, "%s/daily.cvd", dbdir);
79
-		    if(stat(daily, &foo) == -1)
80
-			sprintf(daily, "%s/daily.inc/daily.info", dbdir);
79
+		    if(access(daily, R_OK))
80
+			sprintf(daily, "%s/daily.cld", dbdir);
81 81
 
82 82
 		    if((d2 = cl_cvdhead(daily))) {
83 83
 			free(daily);
... ...
@@ -106,10 +105,8 @@ char *freshdbdir(void)
106 106
 
107 107
 void print_version(void)
108 108
 {
109
-	char *dbdir;
110
-	char *path;
109
+	char *dbdir, *path;
111 110
 	struct cl_cvd *daily;
112
-	struct stat foo;
113 111
 
114 112
 
115 113
     dbdir = freshdbdir();
... ...
@@ -119,11 +116,11 @@ void print_version(void)
119 119
     }
120 120
 
121 121
     sprintf(path, "%s/daily.cvd", dbdir);
122
-    if(stat(path, &foo) == -1)
123
-	sprintf(path, "%s/daily.inc/daily.info", dbdir);
122
+    if(access(path, R_OK))
123
+	sprintf(path, "%s/daily.cld", dbdir);
124 124
     free(dbdir);
125 125
 
126
-    if((daily = cl_cvdhead(path))) {
126
+    if(!access(path, R_OK) && (daily = cl_cvdhead(path))) {
127 127
 	    time_t t = (time_t) daily->stime;
128 128
 
129 129
 	printf("ClamAV "VERSION_EXP"/%d/%s", daily->version, ctime(&t));