Skip to content

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.

2 participants