Skip to content

Commit 87be0c2

Browse files
committed
Fix GH-16809: fopen HTTP wrapper timeout stream context option overflow.
1 parent 73ebc92 commit 87be0c2

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
@@ -215,6 +215,13 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
215215

216216
if (context && (tmpzval = php_stream_context_get_option(context, wrapper->wops->label, "timeout")) != NULL) {
217217
double d = zval_get_double(tmpzval);
218+
219+
if (d > (double) PHP_TIMEOUT_ULL_MAX / 1000000.0) {
220+
php_stream_wrapper_log_error(wrapper, options, "timeout must be lower than " ZEND_ULONG_FMT, (zend_ulong)((double) PHP_TIMEOUT_ULL_MAX / 1000000.0));
221+
zend_string_release(transport_string);
222+
php_url_free(resource);
223+
return NULL;
224+
}
218225
#ifndef PHP_WIN32
219226
timeout.tv_sec = (time_t) d;
220227
timeout.tv_usec = (size_t) ((d - timeout.tv_sec) * 1000000);

0 commit comments

Comments
 (0)