cmd: Use WCMD_output_asis*() for strings that are not supposed to contain formating directives.
Francois Gouget
fgouget at free.fr
Wed Nov 23 17:30:23 CST 2011
Using WCMD_output*() instead could cause crashes.
---
For instance if a filename is '%s'.
This patch should not interfere with the previous one.
programs/cmd/builtins.c | 12 ++++++------
programs/cmd/directory.c | 10 +++++-----
programs/cmd/wcmdmain.c | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 2de897b..37d1780 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -361,7 +361,7 @@ void WCMD_choice (const WCHAR * command) {
ptr = strchrW(opt_c, answer[0]);
if (ptr) {
WCMD_output_asis(answer);
- WCMD_output(newline);
+ WCMD_output_asis(newline);
if (have_console)
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), oldmode);
@@ -965,7 +965,7 @@ void WCMD_echo (const WCHAR *command)
echo_mode = FALSE;
else {
WCMD_output_asis (command);
- WCMD_output (newline);
+ WCMD_output_asis (newline);
}
HeapFree(GetProcessHeap(), 0, trimmed);
}
@@ -1778,7 +1778,7 @@ void WCMD_pause (void)
if (have_console)
SetConsoleMode(hIn, 0);
- WCMD_output(anykey);
+ WCMD_output_asis(anykey);
WCMD_ReadFile(hIn, &key, 1, &count);
if (have_console)
SetConsoleMode(hIn, oldmode);
@@ -2115,7 +2115,7 @@ void WCMD_setshow_default (const WCHAR *command) {
GetCurrentDirectoryW(sizeof(cwd)/sizeof(WCHAR), cwd);
if (strlenW(command) == 0) {
strcatW (cwd, newline);
- WCMD_output (cwd);
+ WCMD_output_asis (cwd);
}
else {
/* Remove any double quotes, which may be in the
@@ -2326,7 +2326,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* Output the prompt */
*p++ = '\0';
- if (strlenW(p) != 0) WCMD_output(p);
+ if (strlenW(p) != 0) WCMD_output_asis(p);
/* Read the reply */
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string)/sizeof(WCHAR), &count);
@@ -2698,7 +2698,7 @@ void WCMD_verify (const WCHAR *command) {
void WCMD_version (void) {
- WCMD_output (version_string);
+ WCMD_output_asis (version_string);
}
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index 03cb952..a5447f5 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -326,7 +326,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Output the results */
if (!bare) {
- if (level != 0 && (entry_count > 0)) WCMD_output (newline);
+ if (level != 0 && (entry_count > 0)) WCMD_output_asis (newline);
if (!recurse || ((entry_count > 0) && done_header==FALSE)) {
static const WCHAR headerW[] = {'D','i','r','e','c','t','o','r','y',' ','o','f',
' ','%','s','\n','\n','\0'};
@@ -430,13 +430,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
strcatW(&temp[toWrite], space);
toWrite++;
if (toWrite > 99) {
- WCMD_output(temp);
+ WCMD_output_asis(temp);
toWrite = 0;
strcpyW(temp, nullW);
}
padding--;
}
- WCMD_output(temp);
+ WCMD_output_asis(temp);
}
} else if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
@@ -472,7 +472,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
}
}
}
- if (addNewLine) WCMD_output (newline);
+ if (addNewLine) WCMD_output_asis (newline);
cur_width = 0;
}
@@ -949,7 +949,7 @@ void WCMD_directory (WCHAR *cmd)
}
} else {
static const WCHAR newLine2[] = {'\n','\n','\0'};
- if (!bare) WCMD_output (newLine2);
+ if (!bare) WCMD_output_asis (newLine2);
}
/* Clear any errors from previous invocations, and process it */
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 090a6f1..5bcdbca 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1512,7 +1512,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_type (p);
break;
case WCMD_VER:
- WCMD_output(newline);
+ WCMD_output_asis(newline);
WCMD_version ();
break;
case WCMD_VERIFY:
--
1.7.7.1
More information about the wine-patches
mailing list