java/src/org/openantivirus/engine/censor/matcharray MatchArrayCensor.java,1.2,1.3

Kurt Huwig <[email protected]> Thu, 20 May 2004 13:04:08 +0000
Newsgroups gmane.comp.security.virus.openantivirus.cvs
Message-ID <[email protected]>
Update of /cvsroot/openantivirus/java/src/org/openantivirus/engine/censor/matcharray
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5363/src/org/openantivirus/engine/censor/matcharray

Modified Files:
	MatchArrayCensor.java 
Log Message:
Added multipart string finder
Speed improvements

Index: MatchArrayCensor.java
===================================================================
RCS file: /cvsroot/openantivirus/java/src/org/openantivirus/engine/censor/matcharray/MatchArrayCensor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- MatchArrayCensor.java	19 May 2004 08:09:50 -0000	1.2
+++ MatchArrayCensor.java	20 May 2004 13:04:06 -0000	1.3
@@ -131,10 +131,11 @@
                           int iLength,
                           int iPrefix,
                           int iSuffix) throws MalwareFoundException {
-        for (int i = iOffset; i < iOffset + iLength; i++) {
-            match &= 0xff;
-            match <<= 8;
-            match |= ab[i] & 0xff;
+        final int prefix = iOffset + iPrefix;
+        final int scanLength = iOffset + iLength;
+        final int postfix = scanLength + iSuffix;
+        for (int i = iOffset; i < scanLength; i++) {
+            match = ((match << 8) | ab[i]) & 0xffff;
             
             final PositionFoundListener[] matchListener = matchArray[match];
             if (matchListener != null) {
@@ -145,8 +146,8 @@
                         ab,
                         iPosition,
                         2,
-                        iPosition - iOffset + iPrefix,
-                        iOffset + iLength - iPosition + iSuffix);
+                        iPosition - prefix,
+                        postfix - iPosition);
                 
                 for (int j = 0; j < matchListener.length; j++) {
                     matchListener[j].positionFound(pfe);



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click