Skip to content

Commit 582c8ef

Browse files
committed
Fix GH-16809: fopen HTTP wrapper timeout stream context option overflow.
1 parent cbb3b93 commit 582c8ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
203203

204204
if (context && (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "timeout")) != NULL) {
205205
double d = zval_get_double(tmpzval);
206+
207+
if (d > (double) PHP_TIMEOUT_ULL_MAX / 1000000.0) {
208+
php_stream_wrapper_log_error(wrapper, options, "timeout must be lower than " ZEND_ULONG_FMT, (zend_ulong)((double) PHP_TIMEOUT_ULL_MAX / 1000000.0));
209+
zend_string_release(transport_string);
210+
php_url_free(resource);
211+
return NULL;
212+
}
206213
#ifndef PHP_WIN32
207214
timeout.tv_sec = (time_t) d;
208215
timeout.tv_usec = (size_t) ((d - timeout.tv_sec) * 1000000);

0 commit comments

Comments
 (0)