Skip to content

Commit

Permalink
Merge pull request #204 from blyxxyz/schannel-max-protocol-off-by-one
Browse files Browse the repository at this point in the history
Fix off-by-one error in schannel's max_protocol_version
  • Loading branch information
sfackler authored Aug 11, 2021
2 parents 41522da + 38b1796 commit 2a394b4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@ jobs:
with:
path: target
key: target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
- run: cargo test
- run: cargo test --features alpn
- run: cargo test --features vendored
- run: cargo test --features vendored,alpn
2 changes: 1 addition & 1 deletion src/imp/schannel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static PROTOCOLS: &'static [Protocol] = &[

fn convert_protocols(min: Option<::Protocol>, max: Option<::Protocol>) -> &'static [Protocol] {
let mut protocols = PROTOCOLS;
if let Some(p) = max.and_then(|max| protocols.get(..max as usize)) {
if let Some(p) = max.and_then(|max| protocols.get(..=max as usize)) {
protocols = p;
}
if let Some(p) = min.and_then(|min| protocols.get(min as usize..)) {
Expand Down
1 change: 1 addition & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ fn server_no_shared_protocol() {
let socket = p!(TcpStream::connect(("localhost", port)));
let builder = p!(TlsConnector::builder()
.add_root_certificate(root_ca)
.min_protocol_version(Some(Protocol::Tlsv11))
.max_protocol_version(Some(Protocol::Tlsv11))
.build());
assert!(builder.connect("localhost", socket).is_err());
Expand Down

0 comments on commit 2a394b4

Please sign in to comment.