Skip to content

Commit

Permalink
fill key with zeros during normalization
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6635 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Feb 1, 2010
1 parent a131ebb commit d8d8562
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/net/yacy/kelondro/blob/HeapReader.java
Expand Up @@ -29,6 +29,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -115,11 +116,15 @@ protected byte[] normalizeKey(byte[] key) {
return normalizeKey(key, this.keylength);
}


private static final byte zero = 0;

protected static byte[] normalizeKey(byte[] key, int keylength) {
if (key.length == keylength) return key;
byte[] k = new byte[keylength];
if (key.length < keylength) {
System.arraycopy(key, 0, k, 0, key.length);
for (int i = key.length; i < keylength; i++) k[i] = zero;
} else {
System.arraycopy(key, 0, k, 0, keylength);
}
Expand Down

0 comments on commit d8d8562

Please sign in to comment.