From ad2143f3b06f629c8e6a5d3a4aa409935182de59 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:28:14 +0200 Subject: [PATCH 1/3] Fix arginfo/zpp violation if zend_hrtime is not available Part of GH-19210. Closes GH-19218. --- ext/standard/hrtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/hrtime.c b/ext/standard/hrtime.c index 6af8bfc9650..831e903e1cc 100644 --- a/ext/standard/hrtime.c +++ b/ext/standard/hrtime.c @@ -46,7 +46,6 @@ delivered timestamp is monotonic and cannot be adjusted. */ PHP_FUNCTION(hrtime) { -#if ZEND_HRTIME_AVAILABLE bool get_as_num = 0; zend_hrtime_t t = zend_hrtime(); @@ -55,6 +54,7 @@ PHP_FUNCTION(hrtime) Z_PARAM_BOOL(get_as_num) ZEND_PARSE_PARAMETERS_END(); +#if ZEND_HRTIME_AVAILABLE if (UNEXPECTED(get_as_num)) { PHP_RETURN_HRTIME(t); } else { From beeeee29783604b80be465d738dc4eee635161c1 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 23 Jul 2025 11:32:16 +0200 Subject: [PATCH 2/3] Handle broken hrtime in ftp Part of GH-19210. Closes GH-19219. --- ext/ftp/ftp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index acdc1522e58..3f9a78a81f0 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1471,7 +1471,8 @@ static int my_poll(php_socket_t fd, int events, int timeout) { if (n == -1 && php_socket_errno() == EINTR) { zend_hrtime_t delta_ns = zend_hrtime() - start_ns; - if (delta_ns > timeout_hr) { + /* delta_ns == 0 is only possible with a platform that does not support a high-res timer. */ + if (delta_ns > timeout_hr || UNEXPECTED(delta_ns == 0)) { #ifndef PHP_WIN32 errno = ETIMEDOUT; #endif From f94c11fff8475acc7b8a39eb4433bd594f73ac3b Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 25 Jul 2025 12:04:40 +0200 Subject: [PATCH 3/3] NEWS for hrtime in FTP and standard --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 89f24c4bfc4..2b21969dffb 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ PHP NEWS . Fixed bug GH-18581 (Coerce numeric string keys from iterators when argument unpacking). (ilutov) +- FTP: + . Fix theoretical issues with hrtime() not being available. (nielsdos) + - Hash: . Fix crash on clone failure. (nielsdos) @@ -34,6 +37,7 @@ PHP NEWS - Standard: . Fixed OSS Fuzz #433303828 (Leak in failed unserialize() with opcache). (ilutov) + . Fix theoretical issues with hrtime() not being available. (nielsdos) 31 Jul 2025, PHP 8.3.24