Skip to content

Commit 2086f34

Browse files
committed
Out of Order Message Handling
1. Always set the expected message right before sending. If the send fails, it is either because the socket is closing, or it is wanting to block. If it is wanting to block, we still want to check the next message as expected.
1 parent 03ca922 commit 2086f34

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

src/internal.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5989,8 +5989,9 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
59895989
}
59905990

59915991
if (ret == WS_SUCCESS) {
5992-
ret = SendNewKeys(ssh);
59935992
ssh->handshake->expectMsgId = MSGID_NEWKEYS;
5993+
WLOG_EXPECT_MSGID(ssh->handshake->expectMsgId);
5994+
ret = SendNewKeys(ssh);
59945995
}
59955996

59965997
if (sigKeyBlock_ptr)
@@ -12729,12 +12730,10 @@ int SendKexDhGexRequest(WOLFSSH* ssh)
1272912730
ret = BundlePacket(ssh);
1273012731
}
1273112732

12732-
if (ret == WS_SUCCESS)
12733-
ret = wolfSSH_SendPacket(ssh);
12734-
1273512733
if (ret == WS_SUCCESS) {
1273612734
WLOG_EXPECT_MSGID(MSGID_KEXDH_GEX_GROUP);
1273712735
ssh->handshake->expectMsgId = MSGID_KEXDH_GEX_GROUP;
12736+
ret = wolfSSH_SendPacket(ssh);
1273812737
}
1273912738

1274012739
WLOG(WS_LOG_DEBUG, "Leaving SendKexDhGexRequest(), ret = %d", ret);
@@ -13086,12 +13085,10 @@ int SendKexDhInit(WOLFSSH* ssh)
1308613085
ret = BundlePacket(ssh);
1308713086
}
1308813087

13089-
if (ret == WS_SUCCESS)
13090-
ret = wolfSSH_SendPacket(ssh);
13091-
1309213088
if (ret == WS_SUCCESS) {
1309313089
WLOG_EXPECT_MSGID(expectMsgId);
1309413090
ssh->handshake->expectMsgId = expectMsgId;
13091+
ret = wolfSSH_SendPacket(ssh);
1309513092
}
1309613093

1309713094
WLOG(WS_LOG_DEBUG, "Leaving SendKexDhInit(), ret = %d", ret);

0 commit comments

Comments
 (0)