swiftlang / swift-foundation

The Foundation project
Apache License 2.0
2.36k stars 150 forks source link

Properly `throw` in case of numeric overflow in Calendar mathematics #900

Closed itingliu closed 3 days ago

itingliu commented 2 weeks ago

We have applied multiple different strategies with regard to overflow during calendrical calculation, including capping input Date and clipping Julian day calculation with artificial bounds. Those are still insufficient as there are too many paths where numeric overflow may happen.

This patch patches those places by throwing whenever applicable. Also adds fuzzing tests to cover many more Calendar API.

Resolves rdar://133558250

itingliu commented 2 weeks ago

@swift-ci please test

itingliu commented 2 weeks ago

@swift-ci please test

itingliu commented 4 days ago

@swift-ci please test