Browse code

fix detection logic in treewalk() to properly work with external unpackers

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

Tomasz Kojm authored on 2005/03/19 09:39:21
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Mar 19 01:35:04 CET 2005 (tk)
2
+---------------------------------
3
+  * clamscan: fix detection logic in treewalk() to properly work with external
4
+	      unpackers (problem reported by Stephen Gran <steve*lobefin.net>)
5
+
1 6
 Sat Mar 19 00:58:19 CET 2005 (tk)
2 7
 ---------------------------------
3 8
   * libclamav: call cli_check_jpeg_exploit() independently of pattern matcher
... ...
@@ -573,7 +573,8 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass
573 573
 	ret = treewalk(gendir, root, user, opt, limits, options);
574 574
 
575 575
     /* remove the directory  - as clamav */
576
-    clamav_rmdirs(gendir);
576
+    if(!optl(opt, "leave-temps"))
577
+	clamav_rmdirs(gendir);
577 578
 
578 579
     /* free gendir - it's not necessary now */
579 580
     free(gendir);
... ...
@@ -101,11 +101,13 @@ int treewalk(const char *dirname, struct cl_node *root, const struct passwd *use
101 101
 
102 102
 		    /* stat the file */
103 103
 		    if(lstat(fname, &statbuf) != -1) {
104
-			if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode) && recursion)
105
-			    treewalk(fname, root, user, opt, limits, options);
106
-			else
104
+			if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode) && recursion) {
105
+			    if(treewalk(fname, root, user, opt, limits, options) == 1)
106
+				scanret++;
107
+			} else {
107 108
 			    if(S_ISREG(statbuf.st_mode))
108 109
 				scanret += scanfile(fname, root, user, opt, limits, options);
110
+			}
109 111
 		    }
110 112
 		    free(fname);
111 113
 		}