diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 14:18:59 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-27 14:18:59 +0000 |
commit | cccbcd174b6ccc352a4d8ae919a8090b4423297a (patch) | |
tree | 8d9eadd28f796c8acc14ff82d740a08b8caceda3 | |
parent | 94e6598969b76d613188ae9015e5d02f31c622a0 (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_4@64564 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.4.5" #define RUBY_RELEASE_DATE "2018-08-27" -#define RUBY_PATCHLEVEL 321 +#define RUBY_PATCHLEVEL 322 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 8 diff --git a/win32/win32.c b/win32/win32.c index 068784e149..5a7e596863 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6765,6 +6765,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) @@ -6819,7 +6823,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; @@ -7077,8 +7081,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: |