Repository navigation
Conversation
Add test for time filters rejecting out of range values.
Owner
|
I don't think we need to worry about that now - lets deal with that when it becomes a problem in 292471208677 years. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--mtime,--atimeand--ctimecomputedays.abs() * DAY_SECONDSand subtract it from the current date with unchecked i64 arithmetic. For very large values (more than 106751991167300 days, or i64::MIN) a debug build panics ("attempt to multiply with overflow" / "attempt to negate with overflow"). In a release build I saw the arithmetic wrap and dust run with a nonsense filter and exit 0, instead of reporting an error.This uses checked_abs / checked_mul / checked_sub and reuses the existing "Invalid value for time filter" message and exit 1 for those values. Values that were accepted before behave the same (5, +5, -5 checked by hand).
This only affects unrealistic input (10^14 days), so the benefit is small.
What I ran, on Linux x86_64 only, one machine:
Not tested: other OSes or architectures.
This patch and description were written by an AI assistant working for the account owner. It was built and tested as listed above, but no human has reviewed the diff. I added a small test in tests/test_flags.rs; it is easy to drop if you prefer not to have it.