Fixed bug which saved an incorrect peer address for a forwarded arbitrary signatures message.

This commit is contained in:
CalDescent 2022-01-01 22:34:02 +00:00
parent fbe34015d4
commit edfc8cfdc4
2 changed files with 5 additions and 1 deletions

View File

@ -395,7 +395,7 @@ public class ArbitraryDataManager extends Thread {
if (existingEntry == null) {
// We haven't got a record of this mapping yet, so add it
LOGGER.debug("Adding arbitrary peer: {} for signature {}", peerAddress, Base58.encode(signature));
ArbitraryPeerData arbitraryPeerData = new ArbitraryPeerData(signature, peer);
ArbitraryPeerData arbitraryPeerData = new ArbitraryPeerData(signature, peerAddress);
repository.discardChanges();
if (!arbitraryPeerData.isPeerAddressValid()) {
return;

View File

@ -29,6 +29,10 @@ public class ArbitraryPeerData {
0, 0, 0L, 0L);
}
public ArbitraryPeerData(byte[] signature, String peerAddress) {
this(Crypto.digest(signature), peerAddress, 0, 0, 0L, 0L);
}
public boolean isPeerAddressValid() {
// Validate the peer address to prevent arbitrary values being added to the db
String[] parts = this.peerAddress.split(":");