Browse code

better message on zip/rar unpacking error

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1607 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2005/06/08 22:39:16
Showing 2 changed files
... ...
@@ -363,7 +363,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
363 363
 
364 364
     if((cli_strbcasestr(filename, ".zip") || cli_strbcasestr(filename, ".rar")) && (options & CL_SCAN_ARCHIVE)) {
365 365
 	/* try to use internal archivers */
366
-	if((ret = checkfile(filename, root, limits, options)) == CL_VIRUS) {
366
+	if((ret = checkfile(filename, root, limits, options, 1)) == CL_VIRUS) {
367 367
 	    if(optl(opt, "remove")) {
368 368
 		if(unlink(filename)) {
369 369
 		    logg("%s: Can't remove\n", filename);
... ...
@@ -383,7 +383,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
383 383
 	}
384 384
 
385 385
 	/* in other case try to continue with external archivers */
386
-	options &= ~CL_SCAN_ARCHIVE; /* and disable decompression for the below checkfile() */
386
+	options &= ~CL_SCAN_ARCHIVE; /* and disable decompression for the checkfile() below */
387 387
     }
388 388
 
389 389
     if((cli_strbcasestr(filename, ".zip") && optl(opt, "unzip"))
... ...
@@ -426,8 +426,7 @@ int scanfile(const char *filename, struct cl_node *root, const struct passwd *us
426 426
 	}
427 427
     }
428 428
 
429
-
430
-    if((ret = checkfile(filename, root, limits, options)) == CL_VIRUS) {
429
+    if((ret = checkfile(filename, root, limits, options, 0)) == CL_VIRUS) {
431 430
 	if(optl(opt, "remove")) {
432 431
 	    if(unlink(filename)) {
433 432
 		logg("%s: Can't remove\n", filename);
... ...
@@ -593,7 +592,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass
593 593
 	    if(!printinfected)
594 594
 		logg("(raw) ");
595 595
 
596
-	    if((ret = checkfile(filename, root, limits, 0)) == CL_VIRUS) {
596
+	    if((ret = checkfile(filename, root, limits, 0, 0)) == CL_VIRUS) {
597 597
 		if(optl(opt, "remove")) {
598 598
 		    if(unlink(filename)) {
599 599
 			logg("%s: Can't remove\n", filename);
... ...
@@ -610,7 +609,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass
610 610
 	case 0:
611 611
 	    /* no viruses found in archive, we scan just in case a raw file
612 612
 	     */
613
-	    if((ret = checkfile(filename, root, limits, 0)) == CL_VIRUS) {
613
+	    if((ret = checkfile(filename, root, limits, 0, 1)) == CL_VIRUS) {
614 614
 		if(optl(opt, "remove")) {
615 615
 		    if(unlink(filename)) {
616 616
 			logg("%s: Can't remove\n", filename);
... ...
@@ -733,7 +732,7 @@ int scandirs(const char *dirname, struct cl_node *root, const struct passwd *use
733 733
 	return treewalk(dirname, root, user, opt, limits, options, 1);
734 734
 }
735 735
 
736
-int checkfile(const char *filename, const struct cl_node *root, const struct cl_limits *limits, int options)
736
+int checkfile(const char *filename, const struct cl_node *root, const struct cl_limits *limits, int options, short printclean)
737 737
 {
738 738
 	int fd, ret;
739 739
 	const char *virname;
... ...
@@ -754,7 +753,7 @@ int checkfile(const char *filename, const struct cl_node *root, const struct cl_
754 754
 	    fprintf(stderr, "\007");
755 755
 
756 756
     } else if(ret == CL_CLEAN) {
757
-	if(!printinfected)
757
+	if(!printinfected && printclean)
758 758
 	    logg("%s: OK\n", filename);
759 759
     } else
760 760
 	if(!printinfected)
... ...
@@ -33,7 +33,7 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd *
33 33
 
34 34
 int scandirs(const char *dirname, struct cl_node *root, const struct passwd *user, const struct optstruct *opt, const struct cl_limits *limits, int options);
35 35
 
36
-int checkfile(const char *filename, const struct cl_node *root, const struct cl_limits *limits, int compr);
36
+int checkfile(const char *filename, const struct cl_node *root, const struct cl_limits *limits, int options, short printclean);
37 37
 
38 38
 int checkstdin(const struct cl_node *root, const struct cl_limits *limits, int options);
39 39