SSU: Return unused DH to the queue

This commit is contained in:
zzz
2014-09-22 18:49:20 +00:00
parent 591f48856d
commit 3331e1c152
2 changed files with 14 additions and 6 deletions

View File

@ -1363,6 +1363,7 @@ class EstablishmentManager {
_transport.markUnreachable(peer); _transport.markUnreachable(peer);
_transport.dropPeer(peer, false, err); _transport.dropPeer(peer, false, err);
//_context.profileManager().commErrorOccurred(peer); //_context.profileManager().commErrorOccurred(peer);
outboundState.fail();
} else { } else {
OutNetMessage msg; OutNetMessage msg;
while ((msg = outboundState.getNextQueuedMessage()) != null) { while ((msg = outboundState.getNextQueuedMessage()) != null) {

View File

@ -201,14 +201,16 @@ class OutboundEstablishState {
/** caller must synch - only call once */ /** caller must synch - only call once */
private void prepareSessionRequest() { private void prepareSessionRequest() {
_keyBuilder = _keyFactory.getBuilder(); _keyBuilder = _keyFactory.getBuilder();
_sentX = new byte[UDPPacketReader.SessionRequestReader.X_LENGTH];
byte X[] = _keyBuilder.getMyPublicValue().toByteArray(); byte X[] = _keyBuilder.getMyPublicValue().toByteArray();
if (X.length == 257) if (X.length == 257) {
_sentX = new byte[256];
System.arraycopy(X, 1, _sentX, 0, _sentX.length); System.arraycopy(X, 1, _sentX, 0, _sentX.length);
else if (X.length == 256) } else if (X.length == 256) {
System.arraycopy(X, 0, _sentX, 0, _sentX.length); _sentX = X;
else } else {
_sentX = new byte[256];
System.arraycopy(X, 0, _sentX, _sentX.length - X.length, X.length); System.arraycopy(X, 0, _sentX, _sentX.length - X.length, X.length);
}
} }
public synchronized byte[] getSentX() { public synchronized byte[] getSentX() {
@ -219,7 +221,7 @@ class OutboundEstablishState {
return _sentX; return _sentX;
} }
/** /**x
* The remote side (Bob) - note that in some places he's called Charlie. * The remote side (Bob) - note that in some places he's called Charlie.
* Warning - may change after introduction. May be null before introduction. * Warning - may change after introduction. May be null before introduction.
*/ */
@ -339,6 +341,11 @@ class OutboundEstablishState {
_receivedEncryptedSignature = null; _receivedEncryptedSignature = null;
_receivedIV = null; _receivedIV = null;
_receivedSignature = null; _receivedSignature = null;
if (_keyBuilder != null) {
if (_keyBuilder.getPeerPublicValue() == null)
_keyFactory.returnUnused(_keyBuilder);
_keyBuilder = null;
}
// sure, there's a chance the packet was corrupted, but in practice // sure, there's a chance the packet was corrupted, but in practice
// this means that Bob doesn't know his external port, so give up. // this means that Bob doesn't know his external port, so give up.
_currentState = OutboundState.OB_STATE_VALIDATION_FAILED; _currentState = OutboundState.OB_STATE_VALIDATION_FAILED;