Commit 2b1b525
authored
[runtime] Checked math in date calculations which may overflow (#242)
## Summary
The fuzzer caught assertion failures due to overflow during some date
calculations. Specifically callers to `make_day` could cause an overflow
if the year argument is high enough. We can fix this by using checked
operations in all functions that could potentially overflow.
This could only cause a crash due to the year argument - months and days
already have their ranges validated or controlled. I also audited the
rest of the date calculations and this was the only potential overflow I
found. All other cases operate on f64s or validate the range of their
inputs. The primary functions that rely on callers to validate inputs to
prevent overflow have been annotated with this fact.
## Tests
Added regression test for failing date calculations in the common cases
I could trigger it.1 parent f04d098 commit 2b1b525
3 files changed
Lines changed: 51 additions & 21 deletions
File tree
- src/js/runtime
- intrinsics
- tests/integration/regression
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
240 | 242 | | |
241 | | - | |
| 243 | + | |
242 | 244 | | |
243 | | - | |
| 245 | + | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
255 | 261 | | |
256 | 262 | | |
257 | | - | |
258 | | - | |
259 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
260 | 268 | | |
261 | 269 | | |
262 | | - | |
263 | | - | |
| 270 | + | |
| 271 | + | |
264 | 272 | | |
265 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
266 | 276 | | |
267 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
268 | 280 | | |
269 | 281 | | |
270 | 282 | | |
| |||
300 | 312 | | |
301 | 313 | | |
302 | 314 | | |
303 | | - | |
304 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
305 | 320 | | |
306 | 321 | | |
307 | 322 | | |
| |||
327 | 342 | | |
328 | 343 | | |
329 | 344 | | |
330 | | - | |
331 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
332 | 350 | | |
333 | | - | |
| 351 | + | |
334 | 352 | | |
335 | 353 | | |
336 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
| 807 | + | |
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
| |||
829 | 830 | | |
830 | 831 | | |
831 | 832 | | |
| 833 | + | |
| 834 | + | |
832 | 835 | | |
833 | 836 | | |
834 | 837 | | |
| |||
840 | 843 | | |
841 | 844 | | |
842 | 845 | | |
843 | | - | |
| 846 | + | |
844 | 847 | | |
845 | 848 | | |
846 | 849 | | |
| |||
935 | 938 | | |
936 | 939 | | |
937 | 940 | | |
| 941 | + | |
938 | 942 | | |
939 | 943 | | |
940 | 944 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments