samba-vscan/clamav vscan-clamav.c,1.1.2.7,1.1.2.8

Rainer Link <[email protected]> Thu, 09 Sep 2004 13:03: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-serv7163

Modified Files:
      Tag: VSCAN_0_3
	vscan-clamav.c 
Log Message:
simplified vscan_close, so that only one #fdef LIBCLAMAV is needed

Patch by Helmut


Index: vscan-clamav.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/clamav/vscan-clamav.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -d -r1.1.2.7 -r1.1.2.8
--- vscan-clamav.c	9 Sep 2004 13:02:53 -0000	1.1.2.7
+++ vscan-clamav.c	9 Sep 2004 13:03:54 -0000	1.1.2.8
@@ -544,10 +544,7 @@
 #endif
 {
 	pstring filepath;
-        int retval, rv, rc;
-#ifndef LIBCLAMAV
-	int sockfd;
-#endif
+        int retval, rv;
 	char client_ip[CLIENT_IP_SIZE];
 
         /* First close the file */
@@ -588,29 +585,31 @@
 	}
 
 
-#ifndef LIBCLAMAV
-	sockfd = vscan_clamav_init();
-        if ( sockfd >= 0 ) {
-#endif
-		safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
-		/* scan only file, do nothing */
+	safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
 #ifdef LIBCLAMAV
-		rv = vscan_clamav_lib_scanfile(filepath, client_ip);
-#else
+	/* scan only file, do nothing */
+	rv = vscan_clamav_lib_scanfile(filepath, client_ip);
+#else	/* LIBCLAMAV */
+	{
+		int sockfd;
+		sockfd = vscan_clamav_init();
+                /* Errors are written from vscan_clamav_init()	*/
+		if ( sockfd < 0 )
+			return retval;
+		/* scan only file, do nothing */
                 rv = vscan_clamav_scanfile(sockfd, filepath, client_ip);
                 vscan_clamav_end(sockfd);
-#endif
-		if ( rv == 1 ) {
-			/* virus was found */
+	}
+#endif	/* LIBCLAMAV */
+
+	if ( rv == 1 ) {
+		/* virus was found */
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
-			rc = vscan_do_infected_file_action(handle, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
+		vscan_do_infected_file_action(handle, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
 #else
-			rc = vscan_do_infected_file_action(&default_vfs_ops, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
+		vscan_do_infected_file_action(&default_vfs_ops, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
 #endif
-		}
-#ifndef LIBCLAMAV
 	}
-#endif
 	return retval;
 }
 



-------------------------------------------------------
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