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

Don't panic if passed in a large max age. #86

Merged
merged 1 commit into from
May 7, 2017

Conversation

erickt
Copy link
Contributor

@erickt erickt commented May 7, 2017

Duration will panic if the number of seconds is greater than 2^63/1000. This just caps the Max-Age to the highest value we can parse.

src/parse.rs Outdated
Ok(val) => {
// Don't panic if the max age seconds is greater than what's supported by
// `Duration`.
let max_value = Duration::max_value().num_seconds();
Copy link
Member

Choose a reason for hiding this comment

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

Can we use min here instead? Something like:

let capped_val = cmp::min(Duration::max_value().num_seconds(), val);
Some(Duration::seconds(capped_val))

@SergioBenitez
Copy link
Member

This is a great catch. Thanks for this!

Duration will panic if the number of seconds is greater than
2^63/1000. This just caps the Max-Age to the highest value we
can parse.
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.

None yet

2 participants