samba-vscan/kaspersky vscan-kavp.c,1.38.2.2,1.38.2.3 vscan-kavp_core.c,1.12.2.1,1.12.2.2

Rainer Link <[email protected]> Sat, 25 Sep 2004 12:27:08 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/kaspersky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6692/kaspersky

Modified Files:
      Tag: VSCAN_0_3
	vscan-kavp.c vscan-kavp_core.c 
Log Message:
make the code a little bit more read-able (esp. the check for return values)


Index: vscan-kavp.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/kaspersky/vscan-kavp.c,v
retrieving revision 1.38.2.2
retrieving revision 1.38.2.3
diff -u -d -r1.38.2.2 -r1.38.2.3
--- vscan-kavp.c	12 Sep 2003 07:12:15 -0000	1.38.2.2
+++ vscan-kavp.c	25 Sep 2004 12:27:05 -0000	1.38.2.3
@@ -388,7 +388,7 @@
 			return default_vfs_ops.open(conn, fname, flags, mode);
 #endif
 			}
-		else if ( filetype_skipscan(filepath) == 1 ) {
+		else if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
 			if ( verbose_file_logging )
 				vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
@@ -405,7 +405,7 @@
 
                         /* must file actually be scanned? */
                         must_be_checked = lrufiles_must_be_checked(filepath, stat_buf.st_mtime);
-                        if ( must_be_checked == -1 ) {
+                        if ( must_be_checked == VSCAN_LRU_DENY_ACCESS ) {
                                 /* file has already been checked and marked as infected */
                                 /* deny access */
                                 if ( verbose_file_logging )
@@ -417,7 +417,7 @@
 				/* deny access */
                                 errno = EACCES;
                                 return -1;
-                        } else if ( must_be_checked == 0 )  {
+                        } else if ( must_be_checked == VSCAN_LRU_GRANT_ACCESS )  {
                                 /* file has already been checked, not marked as infected and not modified */
                                 if ( verbose_file_logging )
                                         vscan_syslog("File '%s' has already been scanned, not marked as infected and not modified. Not scanned anymore. Access granted", filepath);
@@ -436,7 +436,7 @@
 
 			/* scan file */
 			retval = vscan_kavp_scanfile(filepath, client_ip);
-			if ( retval == -2 && deny_access_on_minor_error ) {
+			if ( retval == VSCAN_SCAN_MINOR_ERROR && deny_access_on_minor_error ) {
 				/* a minor error occured - deny access */
 				vscan_syslog("ERROR: daemon failed with a minor error - access to file %s denied", fname);
 				vscan_kavp_end();
@@ -447,7 +447,7 @@
                                 /* deny access */
 				errno = EACCES;
 				return -1;
-                        } else if ( retval == -1 && deny_access_on_error ) {
+                        } else if ( retval == VSCAN_SCAN_ERROR && deny_access_on_error ) {
                                 /* an error occured - can not communicate to daemon - deny access */
                                 vscan_syslog("ERROR: can not communicate to daemon - access to file %s denied", fname);
 				vscan_kavp_end();
@@ -459,7 +459,7 @@
 
                                 errno = EACCES;
                                 return -1;
-			} else if ( retval == 1 ) {
+			} else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
 				/* virus was found */
 				/* close socket */
 				vscan_kavp_end();
@@ -477,7 +477,7 @@
 				/* virus found, deny acces */
 				errno = EACCES; 
 				return -1;
-                        } else if ( retval == 0 ) {
+                        } else if ( retval == VSCAN_SCAN_OK ) {
                                 /* file is clean, add to lrufiles */
                                 lrufiles_add(filepath, stat_buf.st_mtime, False);
                         }
@@ -535,7 +535,7 @@
 	}
 
 	/* don't scan files which are in the list of exclude file types */
-	if ( filetype_skipscan(filepath) == 1 ) {
+	if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
                 if ( verbose_file_logging )
                         vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);
 		return retval;
@@ -549,7 +549,7 @@
 		safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
 		rv = vscan_kavp_scanfile(filepath, client_ip);
 		vscan_kavp_end();
-		if ( rv == 1 ) {
+		if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
 			/* 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);

Index: vscan-kavp_core.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/kaspersky/vscan-kavp_core.c,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -u -d -r1.12.2.1 -r1.12.2.2
--- vscan-kavp_core.c	14 Jul 2003 13:09:16 -0000	1.12.2.1
+++ vscan-kavp_core.c	25 Sep 2004 12:27:06 -0000	1.12.2.2
@@ -2,7 +2,7 @@
  * Core Interface for Kaspersky AntiVirus
  *
  * Copyright (C) Ries van Twisk, [email protected], 2002
- * Copyright (C) Rainer Link, rainer-pBPPa8WU5k41Tgt60Rntydi2O/[email protected], 2002-2003
+ * Copyright (C) Rainer Link, rainer-pBPPa8WU5k41Tgt60Rntydi2O/[email protected], 2002-2004
  * Various fixes by Kevin Wang <kjw-eXSdB+/[email protected]>, 2003
  *
  * This software is licensed under the GNU General Public License (GPL)
@@ -47,7 +47,7 @@
 	/* Check the socket */
 	if (kavp_socket < 0) {
 	    vscan_syslog("ERROR: connection to kavpdaemon was not open!\n");
-    	    return -1;
+    	    return VSCAN_SCAN_ERROR;
 	}
 
 	/* Send scan request to kavdaeon */
@@ -56,24 +56,24 @@
 
 	if ( (result=KAVRequestPath(kavp_socket, scan_file, SILENT )) < 0) {
 	    vscan_syslog("ERROR: KAVRequestMulti() failed (return code: [%d])\n", result);
-	    return -1;
+	    return VSCAN_SCAN_ERROR;
 	}
 
 	/* Receive status back about this file */	
 	if ( (response=KAVResponse(kavp_socket, &exit_code, SILENT, 0)) ==0 ) {
 	    vscan_syslog("ERROR: KAVResponse() failed (return code: [0])\n");
-	    return -1;
+	    return VSCAN_SCAN_ERROR;
 	}
 
 	if ((exit_code & 0xff) - 0x30) {
 	    vscan_kavp_log_virus(scan_file, client_ip);
-	    return 1;	// Found a virus; deny
+	    return VSCAN_SCAN_VIRUS_FOUND;	// Found a virus; deny
 	} 
 	/* else no virus found */
 	if ( verbose_file_logging )
 	    vscan_syslog("INFO: file %s is clean", scan_file);
 
-    return 0;	// Everything seems to be ok
+    return VSCAN_SCAN_OK;	// Everything seems to be ok
 }
 
 /* Initialize VSAPI */



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php