Jason Edmeades : cmd.exe: Fix handling of malformed environment variable expansion.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 4 08:14:42 CDT 2007


Module: wine
Branch: master
Commit: c4885bc46f105dbe372beda92503a78ce0cbbb1f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c4885bc46f105dbe372beda92503a78ce0cbbb1f

Author: Jason Edmeades <jason.edmeades at googlemail.com>
Date:   Sun Jun  3 22:07:44 2007 +0100

cmd.exe: Fix handling of malformed environment variable expansion.

---

 programs/cmd/wcmdmain.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index ae27415..a5cd510 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -1535,9 +1535,15 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start) {
     /* Find the end of the environment variable, and extract name */
     endOfVar = strchrW(start+1, '%');
     if (endOfVar == NULL) {
-      /* FIXME: Some special conditions here depending on whether
+      /* In batch program, missing terminator for % and no following
+         ':' just removes the '%'                                   */
+      s = WCMD_strdupW(start + 1);
+      strcpyW (start, s);
+      free(s);
+
+      /* FIXME: Some other special conditions here depending on whether
          in batch, complex or not, and whether env var exists or not! */
-      return start+1;
+      return start;
     }
     memcpy(thisVar, start, ((endOfVar - start) + 1) * sizeof(WCHAR));
     thisVar[(endOfVar - start)+1] = 0x00;




More information about the wine-cvs mailing list