windows/fixups.py: limit length of string passed in a single call to WriteConsoleW...
authordavid-sarah <david-sarah@jacaranda.org>
Wed, 27 Oct 2010 02:16:36 +0000 (19:16 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Wed, 27 Oct 2010 02:16:36 +0000 (19:16 -0700)
src/allmydata/windows/fixups.py

index ce8af4b205f309a7c4729733f7092b9e33797d99..12c725bccd9e7f44aae39360bf9eb36228ae4491 100644 (file)
@@ -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