Browse code

handle .info files

git-svn: trunk@2123

Tomasz Kojm authored on 2006/07/26 01:34:40
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Jul 25 18:33:06 CEST 2006 (tk)
2
+----------------------------------
3
+  * libclamav/cvd.c: handle .info files
4
+
1 5
 Tue Jul 25 08:30:12 BST 2006 (njh)
2 6
 ----------------------------------
3 7
   * clamav-milter:	Mention Castlecops in report-phish
... ...
@@ -256,22 +256,24 @@ struct cl_cvd *cl_cvdhead(const char *file)
256 256
 	FILE *fs;
257 257
 	char head[513];
258 258
 	int i;
259
+	unsigned int bread;
260
+
259 261
 
260 262
     if((fs = fopen(file, "rb")) == NULL) {
261 263
 	cli_dbgmsg("Can't open CVD file %s\n", file);
262 264
 	return NULL;
263 265
     }
264 266
 
265
-    if((i = fread(head, 1, 512, fs)) != 512) {
266
-	cli_dbgmsg("Short read (%d) while reading CVD head from %s\n", i, file);
267
+    if(!(bread = fread(head, 1, 512, fs))) {
268
+	cli_errmsg("Can't read CVD header of %s\n", file);
267 269
 	fclose(fs);
268 270
 	return NULL;
269 271
     }
270 272
 
271 273
     fclose(fs);
272 274
 
273
-    head[512] = 0;
274
-    for(i = 511; i > 0 && (head[i] == ' ' || head[i] == 10); head[i] = 0, i--);
275
+    head[bread] = 0;
276
+    for(i = bread - 1; i > 0 && (head[i] == ' ' || head[i] == '\n' || head[i] == '\r'); head[i] = 0, i--);
275 277
 
276 278
     return cl_cvdparse(head);
277 279
 }