From 25d8103dde95d78450ca52a6c327f525d3f6af4c Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Tue, 26 Oct 2010 19:16:36 -0700
Subject: [PATCH] windows/fixups.py: limit length of string passed in a single
 call to WriteConsoleW. fixes #1232.

---
 src/allmydata/windows/fixups.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/allmydata/windows/fixups.py b/src/allmydata/windows/fixups.py
index ce8af4b2..12c725bc 100644
--- a/src/allmydata/windows/fixups.py
+++ b/src/allmydata/windows/fixups.py
@@ -129,7 +129,9 @@ def initialize():
                             remaining = len(text)
                             while remaining > 0:
                                 n = DWORD(0)
-                                retval = WriteConsoleW(self._hConsole, text, remaining, byref(n), None)
+                                # There is a shorter-than-documented limitation on the length of the string
+                                # passed to WriteConsoleW (see #1232).
+                                retval = WriteConsoleW(self._hConsole, text, min(remaining, 10000), byref(n), None)
                                 if retval == 0 or n.value == 0:
                                     raise IOError("WriteConsoleW returned %r, n.value = %r" % (retval, n.value))
                                 remaining -= n.value
-- 
2.45.2