samba-vscan/clamav vscan-clamav.c,1.1.2.6,1.1.2.7 vscan-clamav_core.c,1.5.2.7,1.5.2.8

Rainer Link <[email protected]> Thu, 09 Sep 2004 13:02:56 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/clamav
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6905

Modified Files:
      Tag: VSCAN_0_3
	vscan-clamav.c vscan-clamav_core.c 
Log Message:
Errors are always reportet in the syslog
in vscan_open corrected the handle of the max_size parameter
in verbose mode: more info messages why a file isn't scanned

Patch by Helmut


Index: vscan-clamav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- vscan-clamav.c	9 Sep 2004 13:01:29 -0000	1.1.2.6
+++ vscan-clamav.c	9 Sep 2004 13:02:53 -0000	1.1.2.7
@@ -368,28 +368,45 @@
                 return default_vfs_ops.open(conn, fname, flags, mode);
 #endif				
         }
-
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
-        if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 )    /* an error occured */ 
+	else if ( (SMB_VFS_NEXT_STAT(handle, conn, fname, &stat_buf)) != 0 ) {    /* an error occured */ 
+#else
+	else if ( (default_vfs_ops.stat(conn, fname, &stat_buf)) != 0 ) {    /* an error occured */ 
+#endif
+		vscan_syslog("ERROR: File %s not found, not readable or an error occured", fname);
+#if (SMB_VFS_INTERFACE_VERSION >= 6)
 		return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
 #else
-        if ( (default_vfs_ops.stat(conn, fname, &stat_buf)) != 0 )    /* an error occured */ 
 		return default_vfs_ops.open(conn, fname, flags, mode);
 #endif
-	else if ( S_ISDIR(stat_buf.st_mode) ) 	/* is it a directory? */
+	}
+	else if ( S_ISDIR(stat_buf.st_mode) ) { 	/* is it a directory? */
+		if ( verbose_file_logging )
+			vscan_syslog("INFO: File %s is a directory! Not scanned!", fname);
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
 		return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
 #else
 		return default_vfs_ops.open(conn, fname, flags, mode);
 #endif
-	else if ( ( stat_buf.st_size > max_size ) && ( max_size > 0 ) ) /* file is too large */
-		vscan_syslog("INFO: File %s is larger than specified maximum file size! Not scanned!", fname);
-	else if ( stat_buf.st_size == 0 ) /* do not scan empty files */
+	}
+	else if ( ( stat_buf.st_size > max_size ) && ( max_size > 0 ) ) { /* file is too large */
+		if ( verbose_file_logging )
+			vscan_syslog("INFO: File %s is larger than specified maximum file size! Not scanned!", fname);
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
 		return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
 #else
 		return default_vfs_ops.open(conn, fname, flags, mode);
 #endif
+	}
+	else if ( stat_buf.st_size == 0 ) { /* do not scan empty files */
+		if ( verbose_file_logging )
+			vscan_syslog("INFO: File %s has size zero! Not scanned!", fname);
+#if (SMB_VFS_INTERFACE_VERSION >= 6)
+		return SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
+#else
+		return default_vfs_ops.open(conn, fname, flags, mode);
+#endif
+	}
 	else if ( filetype_skipscan(filepath) == 1 ) {
 		if ( verbose_file_logging )
 			vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);

Index: vscan-clamav_core.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav_core.c,v
retrieving revision 1.5.2.7
retrieving revision 1.5.2.8
diff -u -d -r1.5.2.7 -r1.5.2.8
--- vscan-clamav_core.c	9 Sep 2004 13:01:30 -0000	1.5.2.7
+++ vscan-clamav_core.c	9 Sep 2004 13:02:53 -0000	1.5.2.8
@@ -92,19 +92,14 @@
 		vscan_syslog("INFO: file %s is clean", scan_file);
 	}
 	return 0;
-    } else if ( ret == CL_VIRUS ) {  /* virus found */
+    }
+    if ( ret == CL_VIRUS ) {  /* virus found */
 	vscan_clamav_log_virus(scan_file, virname, client_ip);	
 	return 1;
-    } else {  /* error */
-	if (verbose_file_logging) {
-		vscan_syslog("ERROR: file %s not found, not readable or an error occured (lib return code: %d)", scan_file, ret);
-	}
-	return -2;
     }
-		
-   /* shouldn't get there */
-  return -2;
-    
+    /* error */
+    vscan_syslog("ERROR: file %s not found, not readable or an error occured (lib return code: %d)", scan_file, ret);
+    return -2;
 }
 #else	/* LIBCLAMAV */
 
@@ -176,23 +171,21 @@
         
             vscan_clamav_log_virus(scan_file, vir, client_ip);
             return 1;
-        } else if ((p1 = strstr(buff, "OK\n"))) {
+        }
+	if ((p1 = strstr(buff, "OK\n"))) {
             if (verbose_file_logging) {
                 vscan_syslog("INFO: file %s is clean", scan_file);
             }
             return 0;
-        } else {
-            if (verbose_file_logging) {
-                vscan_syslog("ERROR: file %s not found, not readable or an error occured", scan_file);
-            }
-            return -2;
         }
+
+        vscan_syslog("ERROR: file %s not found, not readable or an error occured", scan_file);
+        return -2;
     }
-    
-    if (fpin) {
+    else if (fpin) {
         fclose(fpin);
     }
-    
+
     vscan_syslog("ERROR: can not get result from clamd");
     return -1;
 }



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click