add comments about the null privkey bug

This commit is contained in:
zzz
2010-04-10 15:41:42 +00:00
parent 24020302fd
commit 70e9cf5838
3 changed files with 8 additions and 0 deletions

View File

@ -699,6 +699,7 @@ public class EstablishmentManager {
// signs if we havent signed yet // signs if we havent signed yet
state.prepareSessionConfirmed(); state.prepareSessionConfirmed();
// BUG - handle null return
UDPPacket packets[] = _builder.buildSessionConfirmedPackets(state, _context.router().getRouterInfo().getIdentity()); UDPPacket packets[] = _builder.buildSessionConfirmedPackets(state, _context.router().getRouterInfo().getIdentity());
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))

View File

@ -348,6 +348,8 @@ public class OutboundEstablishState {
DataHelper.toLong(signed, off, 4, _receivedRelayTag); DataHelper.toLong(signed, off, 4, _receivedRelayTag);
off += 4; off += 4;
DataHelper.toLong(signed, off, 4, _sentSignedOnTime); DataHelper.toLong(signed, off, 4, _sentSignedOnTime);
// BUG - if SigningPrivateKey is null, _sentSignature will be null, leading to NPE later
// should we throw something from here?
_sentSignature = _context.dsa().sign(signed, _context.keyManager().getSigningPrivateKey()); _sentSignature = _context.dsa().sign(signed, _context.keyManager().getSigningPrivateKey());
} }

View File

@ -512,6 +512,10 @@ public class PacketBuilder {
* encrypting it as necessary. * encrypting it as necessary.
* *
* @return ready to send packets, or null if there was a problem * @return ready to send packets, or null if there was a problem
*
* TODO: doesn't really return null, and caller doesn't handle null return
* (null SigningPrivateKey should cause this?)
* Should probably return null if buildSessionConfirmedPacket() turns null for any fragment
*/ */
public UDPPacket[] buildSessionConfirmedPackets(OutboundEstablishState state, RouterIdentity ourIdentity) { public UDPPacket[] buildSessionConfirmedPackets(OutboundEstablishState state, RouterIdentity ourIdentity) {
byte identity[] = ourIdentity.toByteArray(); byte identity[] = ourIdentity.toByteArray();
@ -593,6 +597,7 @@ public class PacketBuilder {
off++; off++;
} }
// BUG: NPE here if null signature
System.arraycopy(state.getSentSignature().getData(), 0, data, off, Signature.SIGNATURE_BYTES); System.arraycopy(state.getSentSignature().getData(), 0, data, off, Signature.SIGNATURE_BYTES);
packet.getPacket().setLength(off + Signature.SIGNATURE_BYTES); packet.getPacket().setLength(off + Signature.SIGNATURE_BYTES);
authenticate(packet, state.getCipherKey(), state.getMACKey()); authenticate(packet, state.getCipherKey(), state.getMACKey());