aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common/ct_run.c
diff options
context:
space:
mode:
authorMagnus Ottenklinger <[email protected]>2015-10-02 11:29:05 +0200
committerMagnus Ottenklinger <[email protected]>2015-10-02 15:13:10 +0200
commit731890f3b4ac62eed1221aa7d9fd2bfa6bf51d8c (patch)
tree6517fcce3b266ea067645ac7a8e1b681b03ed7f0 /erts/etc/common/ct_run.c
parent46178552c4622b29d5a70ca23d945e9036caa437 (diff)
downloadotp-731890f3b4ac62eed1221aa7d9fd2bfa6bf51d8c.tar.gz
otp-731890f3b4ac62eed1221aa7d9fd2bfa6bf51d8c.tar.bz2
otp-731890f3b4ac62eed1221aa7d9fd2bfa6bf51d8c.zip
Fix erroneous splitting of emulator path
`ct_run.c`, `erlc.c`, `escript.c` and `typer.c` do not preserve space characters in the emulator path. Thus, if a path containing space is passed via environment variables, such as `ESCRIPT_EMULATOR`, or if `get_default_emulator(progname)` returns a path with space, the execution of the programs fail. This patch fixes all occurrences found with `grep push_words -R $ERL_TOP`.
Diffstat (limited to 'erts/etc/common/ct_run.c')
-rw-r--r--erts/etc/common/ct_run.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/erts/etc/common/ct_run.c b/erts/etc/common/ct_run.c
index 548514ee6c..11cec26264 100644
--- a/erts/etc/common/ct_run.c
+++ b/erts/etc/common/ct_run.c
@@ -83,7 +83,6 @@ static int eargc; /* Number of arguments in eargv. */
static void error(char* format, ...);
static char* emalloc(size_t size);
static char* strsave(char* string);
-static void push_words(char* src);
static int run_erlang(char* name, char** argv);
static char* get_default_emulator(char* progname);
#ifdef __WIN32__
@@ -152,6 +151,8 @@ int main(int argc, char** argv)
argv0 = argv;
emulator = get_default_emulator(argv[0]);
+ if (strlen(emulator) >= MAXPATHLEN)
+ error("Emulator path length is too large");
/*
* Allocate the argv vector to be used for arguments to Erlang.
@@ -163,7 +164,7 @@ int main(int argc, char** argv)
eargv_base = (char **) emalloc(eargv_size*sizeof(char*));
eargv = eargv_base;
eargc = 0;
- push_words(emulator);
+ PUSH(strsave(emulator));
eargc_base = eargc;
eargv = eargv + eargv_size/2;
eargc = 0;
@@ -294,26 +295,6 @@ int main(int argc, char** argv)
return run_erlang(eargv[0], eargv);
}
-static void
-push_words(char* src)
-{
- char sbuf[MAXPATHLEN];
- char* dst;
-
- dst = sbuf;
- while ((*dst++ = *src++) != '\0') {
- if (isspace((int)*src)) {
- *dst = '\0';
- PUSH(strsave(sbuf));
- dst = sbuf;
- do {
- src++;
- } while (isspace((int)*src));
- }
- }
- if (sbuf[0])
- PUSH(strsave(sbuf));
-}
#ifdef __WIN32__
wchar_t *make_commandline(char **argv)
{