From a report[1] on the tz mailing list: In timesub() the weekday is stored in (int) tm_wday before reduction modulo seven (DAYSPERWEEK). Previously this calculation could overflow a 32-bit int, resulting in an incorrect weekday calculation. Calculate two intermediate terms modulo seven to avoid overflow. [1] https://lists.iana.org/hyperkitty/list/tz@iana.org/thread/O3RZGBKSO5GXBFDZKW2JXO3OQIIGYBF3/ PR: 300977
Details
Details
- Reviewers
des - Group Reviewers
releng - Commits
- rGf654a8c0f044: tzcode: Avoid integer truncation resulting in wrong weekday
rG86f463044f95: tzcode: Avoid integer truncation resulting in wrong weekday
rGda83cb9c21e5: tzcode: Avoid integer truncation resulting in wrong weekday
rGecb47941d089: tzcode: Avoid integer truncation resulting in wrong weekday
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
I am confused. leaps_thru_end_of should only ever be returning a small number -- for dates in the current epoch, around 400. That's not something we need to worry about reducing mod 7 to avoid overflows.
I'm wondering if there's a negative-number-being-reinterpreted-as-unsigned issue going on here.
Comment Actions
After https://github.com/eggert/tz/commit/01b367f1511108c8dedfcd036dbffebf58616ada calculates DST transitions relative to atlo = TIME_T_MIN and then converts everything forward. So it runs with a very large negative year.