From cfcf5cfde8a1d69b14c00c8e83c17d529e698729 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 21 Nov 2024 17:51:49 +0100 Subject: [PATCH 1/4] Fix GH-16890: array_sum() with GMP can loose precision (LLP64) We must use `mpz_fits_si_p()` instead of `mpz_fits_slong_p()` since the latter is not suitable for LLP64 data models. libgmp, however, does not define `mpz_fits_si_p()` (which is an mpir addition), so we use `mpz_fits_slong_p()` there which should be fine. Closes GH-16891. --- NEWS | 4 ++++ ext/gmp/gmp.c | 6 +++++- ext/gmp/tests/gh16890.phpt | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ext/gmp/tests/gh16890.phpt diff --git a/NEWS b/NEWS index 30d156a354017..cf40cc748ccf0 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,10 @@ PHP NEWS - GD: . Fixed GH-16776 (imagecreatefromstring overflow). (David Carlier) +- GMP: + . Fixed bug GH-16890 (array_sum() with GMP can loose precision (LLP64)). + (cmb) + - Hash: . Fixed GH-16711: Segfault in mhash(). (Girgias) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 994e95409ad86..dfb762e717c55 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -32,6 +32,10 @@ /* Needed for gmp_random() */ #include "ext/random/php_random.h" +#ifndef mpz_fits_si_p +# define mpz_fits_si_p mpz_fits_slong_p +#endif + #define GMP_ROUND_ZERO 0 #define GMP_ROUND_PLUSINF 1 #define GMP_ROUND_MINUSINF 2 @@ -292,7 +296,7 @@ static zend_result gmp_cast_object(zend_object *readobj, zval *writeobj, int typ return SUCCESS; case _IS_NUMBER: gmpnum = GET_GMP_OBJECT_FROM_OBJ(readobj)->num; - if (mpz_fits_slong_p(gmpnum)) { + if (mpz_fits_si_p(gmpnum)) { ZVAL_LONG(writeobj, mpz_get_si(gmpnum)); } else { ZVAL_DOUBLE(writeobj, mpz_get_d(gmpnum)); diff --git a/ext/gmp/tests/gh16890.phpt b/ext/gmp/tests/gh16890.phpt new file mode 100644 index 0000000000000..08fc060559625 --- /dev/null +++ b/ext/gmp/tests/gh16890.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-16890 (array_sum() with GMP can loose precision (LLP64)) +--EXTENSIONS-- +gmp +--FILE-- + +--EXPECT-- +bool(true) From b263f351c46125156db356a2cfb840c06a8174af Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Sun, 24 Nov 2024 21:30:24 +0700 Subject: [PATCH 2/4] CI: FreeBSD on VM - set `copyback: false` The `vmactions/freebsd-vm` GitHub action rsyncs the work dir to to the VM. This adds a lot of log output due to `rsync -v` usage. Once the tests are compelte, the action copies the files _back_ by running `rsync` in reverse. However, we do not need these files back because we do not run any other steps that need access to the post-test files. Setting `copyback: false` disables this, and cuts the log size by about 5,000 lines. Closes Closes GH-16916. --- .github/actions/freebsd/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/freebsd/action.yml b/.github/actions/freebsd/action.yml index 1abc4b81992d3..ce9ba24451582 100644 --- a/.github/actions/freebsd/action.yml +++ b/.github/actions/freebsd/action.yml @@ -7,6 +7,7 @@ runs: with: release: '13.3' usesh: true + copyback: false # Temporarily disable sqlite, as FreeBSD ships it with disabled double quotes. We'll need to fix our tests. # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269889 prepare: | From 12ef3da381140aa9094ce7fa9f3330ed85791c29 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 19 Nov 2024 00:57:03 +0100 Subject: [PATCH 3/4] Fix potential conflict of copy_variation5-win32.phpt copy_variation1.phpt also creates and deletes a file copy.tmp in the same folder, so conflicts may occur[1]. We apply a quick fix. [1] Closes GH-16854. --- .../tests/file/copy_variation5-win32.phpt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/standard/tests/file/copy_variation5-win32.phpt b/ext/standard/tests/file/copy_variation5-win32.phpt index d3f75262a1857..af352dbe07322 100644 --- a/ext/standard/tests/file/copy_variation5-win32.phpt +++ b/ext/standard/tests/file/copy_variation5-win32.phpt @@ -22,9 +22,9 @@ fclose($file_handle); $dest_files = array( /* Checking case sensitiveness */ - "COPY.tmp", - "COPY.TMP", - "CopY.TMP" + "COPY5.tmp", + "COPY5.TMP", + "CopY5.TMP" ); echo "Size of the source file before copy operation => "; @@ -80,25 +80,25 @@ Size of the source file before copy operation => int(1500) -- Iteration 1 -- Copy operation => bool(true) Existence of destination file => bool(true) -Destination file name => %s/COPY.tmp +Destination file name => %s/COPY5.tmp Size of source file => int(1500) Size of destination file => int(1500) -- Iteration 2 -- Copy operation => bool(true) Existence of destination file => bool(true) -Destination file name => %s/COPY.TMP +Destination file name => %s/COPY5.TMP Size of source file => int(1500) Size of destination file => int(1500) -- Iteration 3 -- Copy operation => bool(true) Existence of destination file => bool(true) -Destination file name => %s/CopY.TMP +Destination file name => %s/CopY5.TMP Size of source file => int(1500) Size of destination file => int(1500) -Warning: unlink(%s/COPY.TMP): No such file or directory in %s on line %d +Warning: unlink(%s/COPY5.TMP): No such file or directory in %s on line %d -Warning: unlink(%s/CopY.TMP): No such file or directory in %s on line %d +Warning: unlink(%s/CopY5.TMP): No such file or directory in %s on line %d *** Done *** From 288776e7f8673c13d71d3da5fd5a35e7f38d74d3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 25 Nov 2024 13:56:58 +0100 Subject: [PATCH 4/4] Drop duplicate macro definitions (GH-16848) Apparently, these have been overlooked when the macro definitions have been moved from dns.c to php_dns.h[1]. [1] --- ext/standard/dns_win32.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index a41d6f44d03a0..616d9eb4368fa 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -23,23 +23,6 @@ #include "php_dns.h" -#define PHP_DNS_NUM_TYPES 12 /* Number of DNS Types Supported by PHP currently */ - -#define PHP_DNS_A 0x00000001 -#define PHP_DNS_NS 0x00000002 -#define PHP_DNS_CNAME 0x00000010 -#define PHP_DNS_SOA 0x00000020 -#define PHP_DNS_PTR 0x00000800 -#define PHP_DNS_HINFO 0x00001000 -#define PHP_DNS_MX 0x00004000 -#define PHP_DNS_TXT 0x00008000 -#define PHP_DNS_A6 0x01000000 -#define PHP_DNS_SRV 0x02000000 -#define PHP_DNS_NAPTR 0x04000000 -#define PHP_DNS_AAAA 0x08000000 -#define PHP_DNS_ANY 0x10000000 -#define PHP_DNS_ALL (PHP_DNS_A|PHP_DNS_NS|PHP_DNS_CNAME|PHP_DNS_SOA|PHP_DNS_PTR|PHP_DNS_HINFO|PHP_DNS_MX|PHP_DNS_TXT|PHP_DNS_A6|PHP_DNS_SRV|PHP_DNS_NAPTR|PHP_DNS_AAAA) - PHP_FUNCTION(dns_get_mx) /* {{{ */ { char *hostname;