From 73ae3e9b4648b49fb54308048aeea17b7a3582e5 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 28 Jul 2018 15:29:14 +0000 Subject: 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/trunk@64092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index 99a20bb0ca..52de2cc63d 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -6822,6 +6822,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) @@ -6876,7 +6880,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; @@ -7138,8 +7142,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: -- cgit v1.2.3