samba-vscan/global vscan-fileregexp.c,1.1.2.1,1.1.2.2

Rainer Link <[email protected]> Fri, 08 Apr 2005 09:06:33 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/samba-vscan/global
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29123/global

Modified Files:
      Tag: VSCAN_0_3
	vscan-fileregexp.c 
Log Message:
some code-rework on file regexp stuff. needs to be tested carefully!


Index: vscan-fileregexp.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/global/Attic/vscan-fileregexp.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-fileregexp.c	29 Mar 2005 19:21:22 -0000	1.1.2.1
+++ vscan-fileregexp.c	8 Apr 2005 09:06:31 -0000	1.1.2.2
@@ -2,7 +2,7 @@
  *
  * Used to skip scanning of certain files (by name and/or path) (user setting)
  *
- * Copyright (c) Rainer Link, 2003-2004
+ * Copyright (c) Rainer Link, 2005
  *	         OpenAntiVirus.org <rainer-pBPPa8WU5k41Tgt60Rntydi2O/[email protected]>
  * Copyright (c) Sven Strickroth, 2005
  *	         <[email protected]>
@@ -38,7 +38,7 @@
 		DEBUG(5, ("exclude regexp is empty - nothing to do\n"));	
 	} /* end if */
 
-	return 0;
+	return True;
 
 } /* end function */
 
@@ -58,20 +58,21 @@
 		if (strlen(fileregexp_excludepattern) > 0) {
 			int ovector[OVECCOUNT];
 			int rc;
-			pcre *exclude_re;
-
+			pcre *exclude_re = NULL;
 			const char *error;
 			int erroffset;
+
+
 			exclude_re = pcre_compile(
-	  fileregexp_excludepattern, /* the pattern */
-	  0,                      /* default options */
-	  &error,                 /* for error message */
-	  &erroffset,             /* for error offset */
-	  NULL);                  /* use default character tables */
+			  fileregexp_excludepattern, /* the pattern */
+			  0,                      /* default options */
+			  &error,                 /* for error message */
+			  &erroffset,             /* for error offset */
+			  NULL);                  /* use default character tables */
 	
 			if (exclude_re == NULL) {
 				DEBUG(0,("PCRE compilation failed at offset %d: %s\n", erroffset, error));
-				return 1;
+				return VSCAN_FR_ERROR_MUST_SCAN;
 			}
 
 
@@ -87,26 +88,32 @@
 
 			/* Matching failed: handle error cases */
 			
-			if (rc < 0)
-			  {
-			  switch(rc)
-			    {
-			    case PCRE_ERROR_NOMATCH: DEBUG(5,("No match\n")); return 0; break;
+			if ( rc < 0 ) {
+			  switch(rc) {
+			    case PCRE_ERROR_NOMATCH: 
+				DEBUG(5,("No match\n")); 
+				SAFE_FREE(exclude_re);
+				return VSCAN_FR_MUST_SCAN; 
+				break;
 			    /*
 			    Handle other special cases if you like
 			    */
-			    default: DEBUG(5,("Matching error %d\n", rc)); return -1; break;
+			    default: 
+				DEBUG(5,("Matching error %d\n", rc)); 
+				SAFE_FREE(exclude_re);
+				return VSCAN_FR_ERROR_MUST_SCAN; 
+				break;
 			    }
-			  SAFE_FREE(exclude_re);     /* Release memory used for the compiled pattern */
-			  return 0;
-			  }
-			
+		  	}
+		
 			/* Match succeded */
+			SAFE_FREE(exclude_re);
 			DEBUG(5,("matched!\n"));
-			return 1;
-		}
+			return VSCAN_FR_SKIP_SCAN;
+		} /* end if */
+
 		DEBUG(5,("no pattern\n"));
-		return 0;
+		return VSCAN_FR_MUST_SCAN;
 }
 
 #else /* HAVE_FILEREGEXP_SUPPORT */



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click