[php-src] PR #17060: Fix integer overflows in timelib
| From: | nielsdos | Date: | Thu, 05 Dec 2024 21:59:27 +0000 |
| Subject: | [php-src] PR #17060: Fix integer overflows in timelib | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-29899@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17060
Author: nielsdos
There are edge cases where computations can cause an integer overflow, which is undefined behaviour.
Lately, some fuzzers seem to be hitting these quite frequently. While this behaviour is undefined,
it doesn't actually matter in practice, the worst effect is having a wrong computation result,
but no sane person would do computations on e.g. the year pow(2,63).
Still, undefined behaviour is bad.
Make the wrapping behaviour defined by using -fwrapv when possible. The scope of this is limited to
timelib and doesn't affect php_date.c.
The reason for this is that this may in theory prevent some optimizations and it also seems bad to
affect code that lives so close to the PHP-native edge.
I tested all issues.
This fixes all but 2 issues, the remaining 2 issues are in php_date.c.
Fixes GH-13881.
Fixes GH-14075.
Fixes GH-15150.
Fixes GH-16034.
Fixes GH-16035.
Fixes GH-16048.
Fixes GH-16050.
Fixes GH-16051.
Fixes GH-16052.
Fixes GH-16775.
Fixes GH-16864.
Fixes GH-16865.
Fixes GH-16975.
Fixes GH-17025.
Fixes GH-17059.
cc @derickr @iluuu1994 @Girgias @petk