From 88c948bc000685e0d9b4bc8528d3693c84311599 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sat, 3 Feb 2007 14:04:23 +0000 Subject: [PATCH] Fix bug "[ 1647131 ] PATH env var not handled properly." Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2797 --- src/shell/shell_misc.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/shell/shell_misc.cpp b/src/shell/shell_misc.cpp index dbdfe404..cb2c7fb3 100644 --- a/src/shell/shell_misc.cpp +++ b/src/shell/shell_misc.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell_misc.cpp,v 1.48 2007-01-21 14:12:02 qbix79 Exp $ */ +/* $Id: shell_misc.cpp,v 1.49 2007-02-03 14:04:23 qbix79 Exp $ */ #include #include @@ -356,7 +356,8 @@ void DOS_Shell::InputCommand(char * line) { bool DOS_Shell::Execute(char * name,char * args) { /* return true => don't check for hardware changes in do_command * return false => check for hardware changes in do_command */ - char * fullname; + char fullname[DOS_PATHLENGTH+4]; //stores results from Which + char* p_fullname; char line[CMD_MAXLINE]; if(strlen(args)!= 0){ if(*args != ' '){ //put a space in front @@ -381,15 +382,17 @@ bool DOS_Shell::Execute(char * name,char * args) { return true; } /* Check for a full name */ - fullname=Which(name); - if (!fullname) return false; - - const char* extension =strrchr(fullname,'.'); + p_fullname = Which(name); + if (!p_fullname) return false; + strcpy(fullname,p_fullname); + const char* extension = strrchr(fullname,'.'); /*always disallow files without extension from being executed. */ /*only internal commands can be run this way and they never get in this handler */ if(extension == 0) { + //Check if the result will fit in the parameters. Else abort + if(strlen(fullname) >( DOS_PATHLENGTH - 1) ) return false; char temp_name[DOS_PATHLENGTH+4],* temp_fullname; //try to add .com, .exe and .bat extensions to filename