1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2018-07-28 15:29:14 +00:00
parent 440f4421ee
commit 73ae3e9b46

View file

@ -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: