Re: [PATCH] wineconsole: Set input stream buffer length per OS limit
On 26.03.2015 14:32, Hugh McMaster wrote:
--- programs/wineconsole/wineconsole.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 3c2faf5..81300ed 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -797,6 +797,11 @@ static UINT WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci) return 0; }
+#define MAXSTRING_NON_NT 128 +#define MAXSTRING_NT351 260 +#define MAXSTRING_NT4_W2K 2048 +#define MAXSTRING_XP 8192 +
Why do you need this mess?
---------------------------------------- On Thu, 26 Mar 2015 14:39:50 +0300, Nikolay Sivov wrote:
On 26.03.2015 14:32, Hugh McMaster wrote:
--- programs/wineconsole/wineconsole.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 3c2faf5..81300ed 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -797,6 +797,11 @@ static UINT WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci) return 0; }
+#define MAXSTRING_NON_NT 128 +#define MAXSTRING_NT351 260 +#define MAXSTRING_NT4_W2K 2048 +#define MAXSTRING_XP 8192 +
Why do you need this mess?
To avoid magic numbers, unless you think that's unnecessary here. The Windows command line (cmd or command.com) limits the maximum length of an input string. [1] The limits are defined as that 'mess' above. :) Windows 3.x, 95, 98, ME --> 128 characters NT 3.51 --> 260 characters NT 4, W2K --> 2048 characters XP, Vista, 7, etc. --> 8192 characters I was actually wondering if using a standard buffer[8192] would be better in this case, as it allocates enough memory for all of the above. Somehow this functionality needs to be extended to cmd itself. Windows blocks input in cmd at the defines -1, e.g. 8191 characters in XP and above. [1] http://support.microsoft.com/en-us/kb/830473
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2015-03-26 um 13:58 schrieb Hugh McMaster:
The Windows command line (cmd or command.com) limits the maximum length of an input string. [1] Do we care about this? Do you have an application that depends on this kind of limit?
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVFBYpAAoJEN0/YqbEcdMwyUIP/12M+6VvYYWqm7/BrEyKaQGz gsLPCA1cSEZ8FOEeD69lzLzSp16pglAoxaN2/MMFaOivml7mEeEtBm2mx3n3ww93 pl/0k7vURzTKzoANfVdzAWHkCgfRP6/emhfv5mZakaVYI8X99MkDC8/kO5j7xOAG SvBb5Q2JJkL7dnuODHNxJwDI6h+JWllqAkv7yB7DiSlcQDVygxCLkpPQJe/rnuaK Elj545AwsAOz8IfI9qOYwVMI1lYRNt/c27H3ixNzI4vMkRpk/u4gSn8+qfMypSmF kiQIfBnk9k9l2CKsNGRlcpbU0eoBlkukmwFdWejnhqhcYl8W0FaxdvfL8m3N9hdP roYyE7Lbb5sj5mvQsvNRoMayZz9DAosVCWcBm2ohRUCLy0x14A2myeIJiDkS2ByF XVgOmZtR6CcIWFUMi4c94Ms0bvPG2gRc9TwinKYrHZFRaxO0xaa5hMHTwpvzp4e9 gM/KvBjlsbqPAKYoLd8Mtc/xBaNtJQvr3bQX5fuyrhlnTk8eSh2HTUEJsfToZyZf qFrvnS/8yK1vhowF69NhVrprNQRlTL6JQ/rgGJFHUnml66y7BNslRrXw7jle1JrN O2X3U3vJgihUxSFxrQcyGsV9vqXbSJYcRedGM9O1SAeKpZ/gFWrRV1RS8mIOG1og oXPOvUTuIOKF+KptcgPj =Yz6G -----END PGP SIGNATURE-----
On Thu, 26 Mar 2015 15:22:33 +0100, Stefan Dösinger wrote:
Am 2015-03-26 um 13:58 schrieb Hugh McMaster:
The Windows command line (cmd or command.com) limits the maximum length of an input string. [1] Do we care about this? Do you have an application that depends on this kind of limit?
Wineconsole currently has fixed buffer of 256 chars. Any input from a terminal that is longer than 256 bytes is truncated. (See also bug 34814.) It is easy to test this with a (deliberately) small buffer, say 32 chars, by altering line 833 in programs/wineconsole/wineconsole.c. Then with a test program: ./wine wineconsole cmd /k ../c.exe -abc -def -ghi -jkl strlen(wci.ptr): 35, malloc'ed: 32 WCHARs [strlen only reads from 'cmd' onwards] input: cmd /k ../c.exe -abc -def -ghi -jkl GetLastError(): 122 [MultiByteToWideChar error: The data area passed to a system call is too small.] lstrlenW(buffer): 32 output: cmd /k ../c.exe -abc -def -ghi - [32 characters. 'jkl' is missing]
participants (3)
-
Hugh McMaster -
Nikolay Sivov -
Stefan Dösinger