Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -3469,14 +3469,31 @@ QuicConnRecvVerNeg(
{
uint32_t SupportedVersion = 0;

// TODO - Validate the packet's SourceCid is equal to our DestCid.
//
// The Version Negotiation packet layout (see QUIC_VERSION_NEGOTIATION_PACKET)
// places the Source CID immediately after the Destination CID:
//
// ... | DestCidLength (1) | DestCid (DestCidLength) |
// SourceCidLength (1) | SourceCid (SourceCidLength) | SupportedVersions...
//
const uint8_t VnSourceCidLen =
Packet->VerNeg->DestCid[Packet->VerNeg->DestCidLength];
const uint8_t* VnSourceCid =
Comment thread
gaurav2699 marked this conversation as resolved.
Packet->VerNeg->DestCid + Packet->VerNeg->DestCidLength + sizeof(uint8_t);

//
// Validate that the packet's Source CID matches our current Destination CID
//
const QUIC_CID_LIST_ENTRY* DestCid = Connection->Paths[0].DestCid;
CXPLAT_DBG_ASSERT(DestCid != NULL);
if (VnSourceCidLen != DestCid->CID.Length ||
memcmp(VnSourceCid, DestCid->CID.Data, VnSourceCidLen) != 0) {
QuicPacketLogDrop(Connection, Packet, "Version Negotiation Source CID doesn't match our Destination CID");
return;
}

const uint32_t* ServerVersionList =
(const uint32_t*)(
Packet->VerNeg->DestCid +
Packet->VerNeg->DestCidLength +
sizeof(uint8_t) + // SourceCidLength field size
Packet->VerNeg->DestCid[Packet->VerNeg->DestCidLength]); // SourceCidLength
(const uint32_t*)(VnSourceCid + VnSourceCidLen);
uint16_t ServerVersionListLength =
(Packet->AvailBufferLength - (uint16_t)((uint8_t*)ServerVersionList - Packet->AvailBuffer)) / sizeof(uint32_t);

Expand Down
Loading