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

Projects
None yet
2 participants
@erickt
Copy link
Contributor

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.

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();

This comment has been minimized.

@SergioBenitez

SergioBenitez May 7, 2017

Collaborator

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

This comment has been minimized.

Copy link
Collaborator

SergioBenitez commented May 7, 2017

This is a great catch. Thanks for this!

Don't panic if passed in a large max age.
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.

@erickt erickt force-pushed the erickt:panic branch from f1ceaac to ee18b79 May 7, 2017

@SergioBenitez SergioBenitez merged commit 9587854 into alexcrichton:master May 7, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment