Fix NPE in race between child response and remote retransmission
IkeSessionStateMachine will get a NullPointerException when it
receives a retransmitted request of the first remote request
before it has sent back a response. The cause is that the
IkeSessionStateMachine tries to send back the cached response but
the cached response value is null.
This is a tactical fix to ensure correctness.
Bug: 159133972
Test: FrameworksIkeTests, CtsIkeTestCases
Change-Id: I97b7af7cde93b623b24f4dd98c338d19c18437b6
diff --git a/src/java/com/android/internal/net/ipsec/ike/IkeSessionStateMachine.java b/src/java/com/android/internal/net/ipsec/ike/IkeSessionStateMachine.java
index 554f84c..d321fbc 100644
--- a/src/java/com/android/internal/net/ipsec/ike/IkeSessionStateMachine.java
+++ b/src/java/com/android/internal/net/ipsec/ike/IkeSessionStateMachine.java
@@ -1668,8 +1668,10 @@
if (ikeSaRecord.isRetransmittedRequest(ikePacketBytes)) {
logd("Received re-transmitted request. Retransmitting response");
- for (byte[] packet : ikeSaRecord.getLastSentRespAllPackets()) {
- mIkeSocket.sendIkePacket(packet, mRemoteAddress);
+ if (ikeSaRecord.getLastSentRespAllPackets() != null) {
+ for (byte[] packet : ikeSaRecord.getLastSentRespAllPackets()) {
+ mIkeSocket.sendIkePacket(packet, mRemoteAddress);
+ }
}
// TODO:Support resetting remote rekey delete timer.