From 7c3f3d09dd589430060f3f0bee6d813e213c65f3 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Thu, 25 Oct 2012 21:17:13 +0100 Subject: [PATCH] cmd: Don't overflow parameter length when copying substring. --- programs/cmd/tests/test_builtins.cmd.exp | 2 +- programs/cmd/wcmdmain.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index aeaa14db048..8a7e3fabda5 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -275,7 +275,7 @@ P0S q qwe er -@todo_wine@'ty'@or_broken@'' +'ty'@or_broken@'' 't'@or_broken@'' ert@or_broken@qwerty e@or_broken@qwerty diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 89c1327686c..534e5a66f04 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -730,6 +730,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, else if (copybytes < 0) copybytes = 0; WCMD_strsubstW(start, endOfVar + 1, startCopy, copybytes); } else { + substrlength = min(substrlength, len - (startCopy- thisVarContents + 1)); WCMD_strsubstW(start, endOfVar + 1, startCopy, substrlength); }