protection against too large seeds

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3877 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 684ded0e09
commit 4f5496062c

@ -79,6 +79,10 @@ public final class hello {
int count = 0; int count = 0;
try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;} try {count = (countStr == null) ? 0 : Integer.parseInt(countStr);} catch (NumberFormatException e) {count = 0;}
// final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(MYTIME)); // read remote time // final Date remoteTime = yacyCore.parseUniversalDate((String) post.get(MYTIME)); // read remote time
if (seed.length() > yacySeed.maxsize) {
yacyCore.log.logInfo("hello/server: rejected contacting seed; too large (" + seed.length() + " > " + yacySeed.maxsize + ")");
return null;
}
final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, false); final yacySeed remoteSeed = yacySeed.genRemoteSeed(seed, key, false);
// System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString())); // System.out.println("YACYHELLO: REMOTESEED=" + ((remoteSeed == null) ? "NULL" : remoteSeed.toString()));

@ -157,12 +157,17 @@ public final class yacyClient {
yacySeed otherPeer = null; yacySeed otherPeer = null;
float otherPeerVersion = 0; float otherPeerVersion = 0;
if (otherHash != null && otherHash.length() > 0) { if (otherHash != null && otherHash.length() > 0) {
otherPeer = yacySeed.genRemoteSeed((String) result.get("seed0"), key, true); String seed = (String) result.get("seed0");
if (otherPeer == null || !otherPeer.hash.equals(otherHash)) { if (seed.length() > yacySeed.maxsize) {
yacyCore.log.logFine("yacyClient.publishMySeed: consistency error: other peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' wrong"); yacyCore.log.logInfo("hello/client 0: rejected contacting seed; too large (" + seed.length() + " > " + yacySeed.maxsize + ")");
return -1; // no success } else {
otherPeer = yacySeed.genRemoteSeed(seed, key, true);
if (otherPeer == null || !otherPeer.hash.equals(otherHash)) {
yacyCore.log.logFine("yacyClient.publishMySeed: consistency error: other peer '" + ((otherPeer==null)?"unknown":otherPeer.getName()) + "' wrong");
return -1; // no success
}
otherPeerVersion = otherPeer.getVersion();
} }
otherPeerVersion = otherPeer.getVersion();
} }
// set my own seed according to new information // set my own seed according to new information
@ -239,7 +244,11 @@ public final class yacyClient {
while ((seedStr = (String) result.get("seed" + i++)) != null) { while ((seedStr = (String) result.get("seed" + i++)) != null) {
// integrate new seed into own database // integrate new seed into own database
// the first seed, "seed0" is the seed of the responding peer // the first seed, "seed0" is the seed of the responding peer
if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key, true), (i == 1))) count++; if (seedStr.length() > yacySeed.maxsize) {
yacyCore.log.logInfo("hello/client: rejected contacting seed; too large (" + seedStr.length() + " > " + yacySeed.maxsize + ")");
} else {
if (yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(seedStr, key, true), (i == 1))) count++;
}
} }
return count; return count;
} }

@ -85,6 +85,7 @@ import de.anomic.tools.crypt;
public class yacySeed { public class yacySeed {
public static final int maxsize = 2048;
/** /**
* <b>substance</b> "sI" (send index/words) * <b>substance</b> "sI" (send index/words)
*/ */

Loading…
Cancel
Save