Skip to content

Commit

Permalink
Correctly discard data after close_notify alert
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz committed May 17, 2024
1 parent 06dc1d5 commit 386b6fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rustls/src/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,8 @@ impl<Data> ConnectionCore<Data> {
{
// "Any data received after a closure alert has been received MUST be ignored."
// -- <https://datatracker.ietf.org/doc/html/rfc8446#section-6.1>
discard = borrowed_buffer.filled().len();
// This is data that has already been accepted in `read_tls`.
discard += borrowed_buffer.filled().len();
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions rustls/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6390,6 +6390,7 @@ fn test_junk_after_close_notify_received() {
.read_tls(&mut io::Cursor::new(&client_buffer[..]))
.unwrap();
server.process_new_packets().unwrap();
server.process_new_packets().unwrap(); // check for desync

// can read data received prior to close_notify
let mut received_data = [0u8; 128];
Expand Down

0 comments on commit 386b6fd

Please sign in to comment.