[freenet-cvs] r17735 - trunk/freenet/src/freenet/clients/http/filter

nextgens at freenetproject.org nextgens at freenetproject.org
Sat Feb 9 01:22:11 UTC 2008


Author: nextgens
Date: 2008-02-09 01:22:11 +0000 (Sat, 09 Feb 2008)
New Revision: 17735

Modified:
   trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
   trunk/freenet/src/freenet/clients/http/filter/PNGFilter.java
Log:
PNGFilter: Re-enable the CRC checking of all chunks

Modified: trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java	2008-02-09 01:20:42 UTC (rev 17734)
+++ trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java	2008-02-09 01:22:11 UTC (rev 17735)
@@ -54,7 +54,7 @@
 		
 		// PNG - has a filter
 		register(new MIMEType("image/png", "png", new String[0], new String[0],
-				true, false, new PNGFilter(true, true, false)/* FIXME: reenable when they work */, null, false, false, false, false, true, false,
+				true, false, new PNGFilter(true, true, true), null, false, false, false, false, true, false,
 				l10n("imagePngReadAdvice"),
 				l10n("imagePngWriteAdvice"), false, null, null));
 		

Modified: trunk/freenet/src/freenet/clients/http/filter/PNGFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/PNGFilter.java	2008-02-09 01:20:42 UTC (rev 17734)
+++ trunk/freenet/src/freenet/clients/http/filter/PNGFilter.java	2008-02-09 01:22:11 UTC (rev 17735)
@@ -11,19 +11,16 @@
 import java.util.HashMap;
 
 import freenet.l10n.L10n;
-import freenet.support.CRC;
 import freenet.support.HTMLNode;
 import freenet.support.HexUtil;
 import freenet.support.Logger;
 import freenet.support.LoggerHook.InvalidThresholdException;
-import freenet.support.OutputStreamLogger;
 import freenet.support.api.Bucket;
 import freenet.support.api.BucketFactory;
 import freenet.support.io.ArrayBucketFactory;
 import freenet.support.io.BucketTools;
 import freenet.support.io.Closer;
 import freenet.support.io.FileBucket;
-import freenet.support.io.FileUtil;
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
@@ -31,6 +28,7 @@
 import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.zip.CRC32;
 
 /**
  * Content filter for PNG's.
@@ -172,12 +170,12 @@
 					dos.write(lengthBytes);
 
 				if(checkCRCs) {
-					long readCRC = ((lengthBytes[0] & 0xff) << 24) + ((lengthBytes[1] & 0xff) << 16) + ((lengthBytes[2] & 0xff) << 8) + (lengthBytes[3] & 0xff);
-					byte[] toCheck = new byte[chunkTypeBytes.length + chunkData.length];
-					System.arraycopy(toCheck, 0, chunkTypeBytes, 0, chunkTypeBytes.length);
-					System.arraycopy(toCheck, 0, chunkData, 0, chunkData.length);
-					long computedCRC = CRC.crc(toCheck);
-
+					long readCRC = (((lengthBytes[0] & 0xff) << 24) + ((lengthBytes[1] & 0xff) << 16) + ((lengthBytes[2] & 0xff) << 8) + (lengthBytes[3] & 0xff)) & 0x00000000ffffffffL;
+					CRC32 crc = new CRC32();
+					crc.update(chunkTypeBytes);
+					crc.update(chunkData);
+					long computedCRC = crc.getValue();
+					
 					if(readCRC != computedCRC) {
 						skip = true;
 						if(logMINOR)




More information about the cvs mailing list