Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in PoolKey::new() #84

Merged
merged 1 commit into from
Jun 23, 2020
Merged

Fix panic in PoolKey::new() #84

merged 1 commit into from
Jun 23, 2020

Conversation

jsha
Copy link
Collaborator

@jsha jsha commented Jun 23, 2020

PoolKey calls unwrap() on an option that can be None. Specifically, the
local variable port can be None when PoolKey is constructed with a Url
whose scheme is unrecognized in url.port_or_known_default().

To fix that, make port an Option. Also, make scheme part of the PoolKey.
This prevents, for instance, a stream opened for https://example.com:9999
being reused on a request for http://example.com:9999.

Remove the test-only pool.get() accessor. This was used in only one test,
agent_pool in range.rs. This seemed like it was testing the agent more
than it was testing ranges, so I moved it to agent.rs and edited to
remove the range-testing parts.

Also, reject unrecognized URLs earlier in connect_socket so they don't
reach try_get_connection.

This fixes a panic that can happen on redirects to schemes unrecognized
by Url.

Remove the test-only pool.get() accessor. This was used in only test,
agent_pool in range.rs. This seemed like it was testing the agent more
than it was testing ranges, so I moved it to agent.rs and edited to
remove the range-testing parts.

Also, reject unrecognized URLs earlier in connect_socket so they don't
reach try_get_connection.
Copy link
Contributor

@lolgesten lolgesten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Changes looks good!

@jsha jsha merged commit 3014f58 into algesten:master Jun 23, 2020
@jsha jsha deleted the poolkey-no-panic branch June 23, 2020 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants