### Description The following code: ```php <?php gmp_export(-9223372036854775808, 9223372036854775807, -9223372036854775808); ``` Resulted in this output: ``` /php-src/ext/gmp/gmp.c:1015:31: runtime error: signed integer overflow: 9223372036854775807 * 8 cannot be represented in type 'long' ``` ### PHP Version nightly ### Operating System ubuntu 22.04
Activity
cmb69 commentedon Oct 13, 2024
would prevent this overflow, but still an unexpected unsigned overflow would occur on the next line, so
sizeneeds to be smaller thanZEND_LONG_MAX/4.ndossche commentedon Oct 13, 2024
@cmb69 Feel free to make a PR, although I don't understand yet how you arrived at
ZEND_LONG_MAX/4.cmb69 commentedon Oct 13, 2024
Would need to divide by 8, but since
sizeis signed, we can double to fit into unsigned; thus divide by 4.However, as I said, that value may still be to large for
php-src/ext/gmp/gmp.c
Line 1016 in 79c71c9
Would probably need another check here.
ndossche commentedon Oct 13, 2024
Right that makes sense indeed
Fix phpGH-16411: gmp_export() can cause overflow
[-]Signed integer overflow in ext/gmp/gmp.c[/-][+]gmp_export() can cause overflow[/+]Fix GH-16411: gmp_export() can cause overflow
Merge branch 'PHP-8.2' into PHP-8.3
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4'