13
0

SystemExec: copy last argument from command line to argv[]

Make sure to copy any part of the command line after the last delimiter
to argv[] when creating a SystemExec with an escaped command line.
This commit is contained in:
Colin Fletcher 2014-05-18 20:49:58 +01:00
parent 57077093b7
commit 7c4259133d

View File

@ -201,7 +201,7 @@ SystemExec::make_argp_escaped(std::string command, const std::map<char, std::str
argp = (char **) malloc(sizeof(char *));
for (i = 0; i < command.length(); i++) {
for (i = 0; i <= command.length(); i++) { // include terminating '\0'
char c = command.c_str()[i];
if (inquotes) {
if (c == '"') {
@ -244,6 +244,7 @@ SystemExec::make_argp_escaped(std::string command, const std::map<char, std::str
break;
case ' ' :
case '\t':
case '\0':
if (arg.length() > 0) {
// if there wasn't already a space or tab, start a new parameter
argp = (char **) realloc(argp, (n + 2) * sizeof(char *));