diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-02 11:23:06 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-09-02 11:23:06 +0000 |
commit | 6d9932a28c94c9a3e54cb4783952c2385c794687 (patch) | |
tree | 52fcd0eec99d65743d0b7b9e20d0b46f66af2a88 | |
parent | e20d3698d766a4af5483d6f719db988ae2ba8e74 (diff) |
merge revision(s) 64092: [Backport #14942]
win32.c: limit write size on console
* win32/win32.c (constat_parse): split long buffer and limit write
size on a console, as well as rb_w32_write.
[ruby-dev:50597] [Bug #14942]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | win32/win32.c | 9 |
2 files changed, 7 insertions, 4 deletions
@@ -1,6 +1,6 @@ #define RUBY_VERSION "2.5.2" #define RUBY_RELEASE_DATE "2018-09-02" -#define RUBY_PATCHLEVEL 88 +#define RUBY_PATCHLEVEL 89 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 9 diff --git a/win32/win32.c b/win32/win32.c index 5cb842ff76..407ab72977 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6818,6 +6818,10 @@ constat_apply(HANDLE handle, struct constat *s, WCHAR w) } } +/* get rid of console writing bug; assume WriteConsole and WriteFile + * on a console share the same limit. */ +static const long MAXSIZE_CONSOLE_WRITING = 31366; + /* License: Ruby's */ static long constat_parse(HANDLE h, struct constat *s, const WCHAR **ptrp, long *lenp) @@ -6872,7 +6876,7 @@ constat_parse(HANDLE h, struct constat *s, const WCHAR **ptrp, long *lenp) } rest = 0; } - else { + else if ((rest = *lenp - len) < MAXSIZE_CONSOLE_WRITING) { continue; } *ptrp = ptr; @@ -7130,8 +7134,7 @@ rb_w32_write(int fd, const void *buf, size_t size) ret = 0; retry: - /* get rid of console writing bug */ - len = (_osfile(fd) & FDEV) ? min(32 * 1024, size) : size; + len = (_osfile(fd) & FDEV) ? min(MAXSIZE_CONSOLE_WRITING, size) : size; size -= len; retry2: |