[PATCH] wineconsole: Set input stream buffer length per OS limit
Hugh McMaster
hugh.mcmaster at outlook.com
Thu Mar 26 06:32:45 CDT 2015
---
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
+
/******************************************************************
* WinMain
*
@@ -830,9 +835,32 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
break;
case from_process_name:
{
- WCHAR buffer[256];
+ OSVERSIONINFOW osv;
+ WCHAR *buffer;
+ int max_cmd_str_len = MAXSTRING_NON_NT;
+
+ /* The maximum length of a command prompt string depends on the OS platform and version */
+ osv.dwOSVersionInfoSize = sizeof(osv);
+ GetVersionExW(&osv);
+
+ if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ {
+ /* Windows NT 3.51 */
+ if (osv.dwMajorVersion == 3)
+ max_cmd_str_len = MAXSTRING_NT351;
+ /* Windows NT 4, 2000 */
+ else if (osv.dwMajorVersion == 4 || (osv.dwMajorVersion == 5 && osv.dwMinorVersion == 0))
+ max_cmd_str_len = MAXSTRING_NT4_W2K;
+ /* Windows XP and higher */
+ else if ((osv.dwMajorVersion > 5) || (osv.dwMajorVersion == 5 && osv.dwMinorVersion >= 1))
+ max_cmd_str_len = MAXSTRING_XP;
+ }
+
+ buffer = HeapAlloc(GetProcessHeap(), 0, max_cmd_str_len * sizeof(WCHAR));
+ if (!buffer)
+ return 0;
- MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, sizeof(buffer) / sizeof(buffer[0]));
+ MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, max_cmd_str_len);
if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow)))
return 0;
--
1.9.1
More information about the wine-patches
mailing list