samba-vscan/antivir vscan-antivir.c,1.1.2.1,1.1.2.2 vscan-antivir_core.c,1.1.2.1,1.1.2.2

Rainer Link <[email protected]> Mon, 17 Jan 2005 20:43:13 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/antivir
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7421

Modified Files:
      Tag: VSCAN_0_3
	vscan-antivir.c vscan-antivir_core.c 
Log Message:
some changes to be in sync with upcoming 0.3.6


Index: vscan-antivir_core.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/antivir/Attic/vscan-antivir_core.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- vscan-antivir_core.c	17 Nov 2004 19:21:04 -0000	1.1.2.1
+++ vscan-antivir_core.c	17 Jan 2005 20:43:09 -0000	1.1.2.2
@@ -133,7 +133,7 @@
  *  1 if a concern was found
  */
 int vscan_antivir_scanfile(int sockfd, char *scan_file, char *client_ip) {
-	char *request;
+	char *request = NULL;
 	size_t len;
 	int bEsc;
 	char escbuff[5];	/* "\\xNN" plus NUL */
@@ -142,7 +142,7 @@
 
 	/* (re)connect to the scanner process */
 	if (connect_to_scanner() < 0)
-		return(-1);
+		return VSCAN_SCAN_ERROR;
 
 	/* prepare antivir command (SCAN request) */
 	/* +1 is for '\0' termination --metze */
@@ -156,9 +156,9 @@
 		}
 	}
 	request = (char *)malloc(len);
-	if (NULL == request) {
+	if ( request == NULL ) {
 		vscan_syslog("ERROR: can not allocate memory");
-		return -1; /* error allocating memory */
+		return VSCAN_SCAN_ERROR; /* error allocating memory */
 	}
 	safe_strcpy(request, "SCAN:", len-1);
 	if (! bEsc) {
@@ -188,7 +188,7 @@
 	if (len != strlen(request)) {
 		free(request);
 		vscan_syslog("ERROR: can not write to the antivir socket");
-		return -1; /* error writing to the antivir socket */
+		return VSCAN_SCAN_ERROR; /* error writing to the antivir socket */
 	}
 	free(request);
 	request = NULL;
@@ -235,19 +235,20 @@
 		/* found an alert */
 		if (strcmp(p1, "FOUND") == 0) {
 			vscan_antivir_log_alert(scan_file, p2, client_ip);
-			return 1;
+			return VSCAN_SCAN_VIRUS_FOUND;
 		/* file good */
 		} else if (strcmp(p1, "OK") == 0) {
 			if (verbose_file_logging) {
 				vscan_syslog("INFO: file %s is clean", scan_file);
 			}
-			return 0;
+			return VSCAN_SCAN_OK;
 		/* no explicit check for "ERROR", caught here, too */
 		} else {
 			if (verbose_file_logging) {
 				vscan_syslog("ERROR: file %s not found, not readable or an error occured", scan_file);
 			}
-			return -2;
+			/* FIXME: should this really reported as minor error? */
+			return VSCAN_SCAN_MINOR_ERROR;
 		}
 	} while (0);
 
@@ -255,7 +256,7 @@
 	disconnect_from_scanner();
 
 	vscan_syslog("ERROR: can not get result from antivir");
-	return -1;
+	return VSCAN_SCAN_ERROR;
 }
 
 

Index: vscan-antivir.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/antivir/Attic/vscan-antivir.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -d -r1.1.2.1 -r1.1.2.2
--- vscan-antivir.c	17 Nov 2004 19:21:04 -0000	1.1.2.1
+++ vscan-antivir.c	17 Jan 2005 20:43:07 -0000	1.1.2.2
@@ -403,7 +403,7 @@
 #else
 		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)
@@ -427,7 +427,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 containing an alert */
 				/* deny access */
 				if ( verbose_file_logging )
@@ -439,7 +439,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 containing an alert and not modified */
 				if ( verbose_file_logging )
 					vscan_syslog("File '%s' has already been scanned, not marked as containing an alert and not modified. Not scanned anymore. Access granted", filepath);
@@ -458,7 +458,7 @@
 
 			/* scan file */
 			retval = vscan_antivir_scanfile(sockfd, 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_antivir_end(sockfd);
@@ -469,7 +469,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);
 				/* to be safe, remove file from lrufiles */
@@ -479,7 +479,7 @@
 
 				errno = EACCES;
 				return -1;
-			} else if ( retval == 1 ) {
+			} else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
 				/* an alert was found */
 				vscan_antivir_end(sockfd);
 				/* do action ... */
@@ -496,7 +496,7 @@
 				/* alert 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);
 			}
@@ -554,7 +554,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;
@@ -567,7 +567,7 @@
 		/* scan only file, do nothing */
 		rv = vscan_antivir_scanfile(sockfd, filepath, client_ip);
 		vscan_antivir_end(sockfd);
-		if ( rv == 1 ) {
+		if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
 			/* alert was found */
 #if (SMB_VFS_INTERFACE_VERSION >= 6)
 			rc = vscan_do_infected_file_action(handle, fsp->conn, filepath, quarantine_dir, quarantine_prefix, concerning_file_action);



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt