Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7484394

Browse files
committed
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. Close GH-14022
1 parent 2dbe2d6 commit 7484394

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.2.20
44

5+
- CGI:
6+
. Fixed buffer limit on Windows, replacing read call usage by _read.
7+
(David Carlier)
8+
59
- DOM:
610
. Fix crashes when entity declaration is removed while still having entity
711
references. (nielsdos)

‎main/fastcgi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,9 +965,9 @@ static inline ssize_t safe_read(fcgi_request *req, const void *buf, size_t count
965965
tmp = count - n;
966966

967967
if (!req->tcp) {
968-
unsigned int in_len = tmp > UINT_MAX ? UINT_MAX : (unsigned int)tmp;
968+
unsigned int in_len = tmp > INT_MAX ? INT_MAX : (unsigned int)tmp;
969969

970-
ret = read(req->fd, ((char*)buf)+n, in_len);
970+
ret = _read(req->fd, ((char*)buf)+n, in_len);
971971
} else {
972972
int in_len = tmp > INT_MAX ? INT_MAX : (int)tmp;
973973

‎sapi/cgi/cgi_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes)
486486
while (read_bytes < count_bytes) {
487487
#ifdef PHP_WIN32
488488
size_t diff = count_bytes - read_bytes;
489-
unsigned int to_read = (diff > UINT_MAX) ? UINT_MAX : (unsigned int)diff;
489+
unsigned int to_read = (diff > INT_MAX) ? INT_MAX : (unsigned int)diff;
490490

491-
tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, to_read);
491+
tmp_read_bytes = _read(STDIN_FILENO, buffer + read_bytes, to_read);
492492
#else
493493
tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes);
494494
#endif

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /