From 370a1e8e938d03c04bcfc43dd89e8ad53078acdc Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 20 Apr 2024 20:03:48 +0100 Subject: [PATCH 1/2] sapi/cgi: fix buffer limit on windows. MSDN recommends dropping the deprecated `read` in favor of `_read`. Also, the buffer size limit is INT_MAX. --- main/fastcgi.c | 4 ++-- sapi/cgi/cgi_main.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main/fastcgi.c b/main/fastcgi.c index df309df9fdc7..85e73f2d8bfe 100644 --- a/main/fastcgi.c +++ b/main/fastcgi.c @@ -965,9 +965,9 @@ static inline ssize_t safe_read(fcgi_request *req, const void *buf, size_t count tmp = count - n; if (!req->tcp) { - unsigned int in_len = tmp > UINT_MAX ? UINT_MAX : (unsigned int)tmp; + unsigned int in_len = tmp > INT_MAX ? INT_MAX : (unsigned int)tmp; - ret = read(req->fd, ((char*)buf)+n, in_len); + ret = _read(req->fd, ((char*)buf)+n, in_len); } else { int in_len = tmp > INT_MAX ? INT_MAX : (int)tmp; diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index b45468031fcd..1b95afd7acd3 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -486,9 +486,9 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes) while (read_bytes < count_bytes) { #ifdef PHP_WIN32 size_t diff = count_bytes - read_bytes; - unsigned int to_read = (diff > UINT_MAX) ? UINT_MAX : (unsigned int)diff; + unsigned int to_read = (diff > INT_MAX) ? INT_MAX : (unsigned int)diff; - tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, to_read); + tmp_read_bytes = _read(STDIN_FILENO, buffer + read_bytes, to_read); #else tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes); #endif From 95185f461f61be2c1504d881f71db05cfd095263 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 20 Apr 2024 20:25:45 +0100 Subject: [PATCH 2/2] trigger