summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-28 15:29:14 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-28 15:29:14 (GMT)
commit73ae3e9b4648b49fb54308048aeea17b7a3582e5 (patch)
tree51ed7fc826cdf3cc1e5ea9c5159befc9f9d9a17f /win32/win32.c
parent440f4421ee068849fdf7e1698af903530bf51052 (diff)
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
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 99a20bb..52de2cc 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: