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

time: Year overflow for time.Date #5923

Closed
gbin opened this issue Jul 19, 2013 · 4 comments

Comments

Projects
None yet
5 participants
@gbin
Copy link

commented Jul 19, 2013

What steps will reproduce the problem?
// Get the value of 
time.Unix(-0x7FFFFFFBF5184BFB, -0x8000000000000000).Year() // good -292277022399
// and compare it to the one just below 
time.Unix(-0x7FFFFFFBF5184BFC, -0x8000000000000000).Year() // bad 292277026854

You can play with it here : http://play.golang.org/p/SnAdKtD-_y

What is the expected output?
Year should be in the same order as the timestamp

What do you see instead?
Year overflows

Which compiler are you using (5g, 6g, 8g, gccgo)?
gc/bin/go tool 6g

Which operating system are you using?
Linux 64bits

Which version are you using?  (run 'go version')
go version go1.1.1 linux/amd64

Please provide any additional information below.
It might be completely minor but I could imagine some security issues in validation
functions checking if the year of a given date is in the past.
@remyoudompheng

This comment has been minimized.

Copy link
Contributor

commented Jul 20, 2013

Comment 1:

See also issue #5011.
I don't think it is yet decided how to handle overflows here.
@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2013

Comment 2:

We should probably clamp these.

Labels changed: added priority-later, go1.2maybe, removed priority-triage.

Status changed to Accepted.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2013

Comment 3:

Labels changed: added feature.

@robpike

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2013

Comment 4:

I believe this has been fixed by https://golang.org/cl/10328043
The example looks correct at tip.

Status changed to Fixed.

@gbin gbin added fixed labels Aug 21, 2013

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015

@rsc rsc removed the go1.2maybe label Apr 14, 2015

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.