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

Expiration time fails after about 6050 days from now #102

Open
Qythyx opened this issue Jun 17, 2021 · 2 comments
Open

Expiration time fails after about 6050 days from now #102

Qythyx opened this issue Jun 17, 2021 · 2 comments

Comments

@Qythyx
Copy link

Qythyx commented Jun 17, 2021

@jamesmontemagno

In FileStore.Barrel the DateTimeToEpochSeconds converts the expiration date to second from epoch in seconds as an int. This overflows in about 6050 days from now and becomes int.MinValue, which means it is considered expired. This int should probably be a long instead.

If I have time I'll try to patch this, but I wanted to mention this. Also, I didn't look at the other implementations, only FileStore.

In case you're wondering, I found this problem by trying to set a very distant expiration date. Initially I tried TimeSpan.MaxValue but that had this problem. I then tried TimeSpan.FromDays(9999) and had the same problem. Then I looked at the code and found the problem. I also think that TimeSpan.MaxValue should possibly be considered special and never expire.

@Qythyx
Copy link
Author

Qythyx commented Jun 17, 2021

Ok, I won't be able to patch this. I'm on a Mac and the project is super unhappy opening it in Visual Studio for Mac or VSCode on Mac.

Looking at the code I think just changing a few ints to longs maybe enough, but I would prefer to write a test to exercise this.

@Jeanjean
Copy link

Could this also be causing a System.ArgumentOutOfRangeException when calling Barrel.Current.Add(key, value, TimeSpan.MaxValue);? The error message is: The added or subtracted value results in an un-representable DateTime.
Parameter name: value'. Looks like a regression of #30.

Changing the call to Barrel.Current.Add(key, value, TimeSpan.FromDays(6000)); seems to work as a workaround.

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

No branches or pull requests

2 participants