-
Notifications
You must be signed in to change notification settings - Fork 278
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
Fix integer overflow in leap year calculation #1955
Conversation
c6ad0d9
to
112d24d
Compare
Codecov Report
@@ Coverage Diff @@
## main #1955 +/- ##
=======================================
Coverage 61.13% 61.13%
=======================================
Files 96 96
Lines 19068 19054 -14
Branches 9745 9732 -13
=======================================
- Hits 11657 11649 -8
+ Misses 5093 5092 -1
+ Partials 2318 2313 -5
Continue to review full report at Codecov.
|
Indeed, see https://en.wikipedia.org/wiki/Leap_year#Gregorian_calendar (and the "Algorithm" subsection). Maybe the comment should also say something like "Assuming Gregorian calendar since 1582; years before are assumed to be using the proleptic Gregorian calendar and years <1 are assumed to be using astronomical year numbering" |
See also https://en.wikipedia.org/wiki/ISO_8601#Years basically saying the convention for any year before 1582 has to be clearly agreed/identified between communicating parties. |
If we get a contributor from Vatican City, we could ask her to deal with this. |
…l?id=39555 Remove bogus code.
112d24d
to
4bc4757
Compare
Fixes: #1954
Credit to OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39555
This code looks completely bogus to me. I can't find any reference online that says that negative years should be treated different in a leap year calculation. So the simplest solution to the integer overflow bug is to comment this code out.