cmd: Handle truncation for console reads.

This commit is contained in:
Frédéric Delanoy 2011-10-01 13:43:18 +02:00 committed by Alexandre Julliard
parent e3a72698c1
commit 5e8893f2f6

View file

@ -199,7 +199,12 @@ WCHAR *WCMD_fgets(WCHAR *s, int noChars, HANDLE h, BOOL is_console_handle)
if (is_console_handle) {
status = ReadConsoleW(h, s, noChars, &charsRead, NULL);
if (!status) return NULL;
s[charsRead-2] = '\0'; /* Strip \r\n */
if (s[charsRead-2] == '\r')
s[charsRead-2] = '\0'; /* Strip \r\n */
else {
/* Truncate */
s[noChars-1] = '\0';
}
return p;
}