use orig_dst_cid to add into index to avoid corruption #1980
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
When the initial packet is a stateless retry packet, we use the orig_dst_cid to create the quinn_proto::Incoming. However we added the connection into the index using the header.dst_cid. These two connection CID can be different. When the connection is later removed from the index, we use the one populated in the Incoming. This will fail to properly remove it. This causes discrepancy of the Quinn_proto::Endpoint::index and Quinn_proto::Endpoint::incoming_buffers and cause crashes when the incoming buffer is accessed. A scenario
let incoming_buffer = &mut self.incoming_buffers[incoming_idx];
it will blows up due to wrong index as it was removed in step 2.
Changes:
in Quinn_proto::Endpoint::handle_first_packet use the orig_dst_cid variable to the index to keep consistent with the Incoming created.