Pin expectMsgId after KEXDH_GEX_GROUP

- Set expectMsgId to MSGID_KEXDH_GEX_INIT so the server rejects
  any other KEX message at this stage (RFC 4419 sec 3).
- Reject NULL ssh->handshake in the entry check now that the
  success path dereferences it.

Issue: F-3668
pull/977/head
John Safranek 2026-05-12 11:05:39 -07:00 committed by Paul Adelsbach
parent 822c09d0eb
commit bd75cb4069
1 changed files with 5 additions and 2 deletions

View File

@ -13478,7 +13478,7 @@ int SendKexDhGexGroup(WOLFSSH* ssh)
int ret = WS_SUCCESS;
WLOG(WS_LOG_DEBUG, "Entering SendKexDhGexGroup()");
if (ssh == NULL)
if (ssh == NULL || ssh->handshake == NULL)
ret = WS_BAD_ARGUMENT;
if (ret == WS_SUCCESS) {
@ -13525,8 +13525,11 @@ int SendKexDhGexGroup(WOLFSSH* ssh)
ret = BundlePacket(ssh);
}
if (ret == WS_SUCCESS)
if (ret == WS_SUCCESS) {
WLOG_EXPECT_MSGID(MSGID_KEXDH_GEX_INIT);
ssh->handshake->expectMsgId = MSGID_KEXDH_GEX_INIT;
ret = wolfSSH_SendPacket(ssh);
}
WLOG(WS_LOG_DEBUG, "Leaving SendKexDhGexGroup(), ret = %d", ret);
return ret;