i2psnark: Prevent RuntimeException caused by corrupt i2psnark.dht.dat file

http://forum.i2p/viewtopic.php?t=12751
This commit is contained in:
zzz
2017-03-09 19:34:30 +00:00
parent 1fe9acefe2
commit 9146f3c7e1

View File

@ -106,11 +106,11 @@ class NodeInfo extends SimpleDataStructure {
if (parts.length != 4) if (parts.length != 4)
throw new DataFormatException("Bad format"); throw new DataFormatException("Bad format");
byte[] nid = Base64.decode(parts[0]); byte[] nid = Base64.decode(parts[0]);
if (nid == null) if (nid == null || nid.length != NID.HASH_LENGTH)
throw new DataFormatException("Bad NID"); throw new DataFormatException("Bad NID");
nID = new NID(nid); nID = new NID(nid);
byte[] h = Base64.decode(parts[1]); byte[] h = Base64.decode(parts[1]);
if (h == null) if (h == null || h.length != Hash.HASH_LENGTH)
throw new DataFormatException("Bad hash"); throw new DataFormatException("Bad hash");
//hash = new Hash(h); //hash = new Hash(h);
hash = Hash.create(h); hash = Hash.create(h);