From 93a68fa6594907078d69d813f6b58cee35abe8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delanoy?= Date: Sat, 27 Aug 2011 02:11:31 +0200 Subject: [PATCH] cmd: Avoid reading garbage when looking for redirection handle. --- programs/cmd/wcmdmain.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 2c1c2e5b7ab..b282e998f86 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1354,11 +1354,10 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, while (redir != NULL && ((p = strchrW(redir,'>')) != NULL)) { int handle = 0; - if (*(p-1)!='2') { - handle = 1; - } else { + if (p > redir && (*(p-1)=='2')) handle = 2; - } + else + handle = 1; p++; if ('>' == *p) {