aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZandra <[email protected]>2015-11-17 13:01:37 +0100
committerZandra <[email protected]>2015-11-17 13:01:37 +0100
commitd42741c7ec0cfe8287a2866a5e837d4da26a97ca (patch)
tree6c8276306e5c269613901f11df0cfe09e47c44b4
parent68a045f8d649fdd77cc704e39e9e4dc331693a90 (diff)
parent731890f3b4ac62eed1221aa7d9fd2bfa6bf51d8c (diff)
downloadotp-d42741c7ec0cfe8287a2866a5e837d4da26a97ca.tar.gz
otp-d42741c7ec0cfe8287a2866a5e837d4da26a97ca.tar.bz2
otp-d42741c7ec0cfe8287a2866a5e837d4da26a97ca.zip
Merge branch 'evnu/fix-whitespace-splitting' into maint
* evnu/fix-whitespace-splitting: Fix erroneous splitting of emulator path
-rw-r--r--erts/etc/common/ct_run.c25
-rw-r--r--erts/etc/common/dialyzer.c24
-rw-r--r--erts/etc/common/erlc.c22
-rw-r--r--erts/etc/common/escript.c25
-rw-r--r--erts/etc/common/typer.c26
5 files changed, 11 insertions, 111 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)
{
diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c
index c45626606c..cac1464bf6 100644
--- a/erts/etc/common/dialyzer.c
+++ b/erts/etc/common/dialyzer.c
@@ -65,7 +65,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__
@@ -189,7 +188,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;
@@ -269,27 +268,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)
{
diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c
index f9d909e01c..049afc526a 100644
--- a/erts/etc/common/erlc.c
+++ b/erts/etc/common/erlc.c
@@ -200,7 +200,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;
@@ -330,26 +330,6 @@ process_opt(int* pArgc, char*** pArgv, int offset)
return argv[1];
}
-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)
{
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c
index 7fd02ed436..a5c6d0d40b 100644
--- a/erts/etc/common/escript.c
+++ b/erts/etc/common/escript.c
@@ -74,7 +74,6 @@ static void error(char* format, ...);
static char* emalloc(size_t size);
static void efree(void *p);
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__
@@ -432,7 +431,7 @@ main(int argc, char** argv)
emulator = get_default_emulator(argv[0]);
}
- if (strlen(emulator) >= PMAX)
+ if (strlen(emulator) >= MAXPATHLEN)
error("Value of environment variable ESCRIPT_EMULATOR is too large");
/*
@@ -445,7 +444,7 @@ 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;
@@ -554,26 +553,6 @@ main(int argc, char** argv)
return run_erlang(eargv[0], eargv);
}
-static void
-push_words(char* src)
-{
- char sbuf[PMAX];
- 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)
{
diff --git a/erts/etc/common/typer.c b/erts/etc/common/typer.c
index 0aa0996808..7ff8aa76e2 100644
--- a/erts/etc/common/typer.c
+++ b/erts/etc/common/typer.c
@@ -65,7 +65,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__
@@ -129,6 +128,9 @@ main(int argc, char** 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.
* Arrange for starting to pushing information in the middle of
@@ -139,7 +141,7 @@ 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;
@@ -192,26 +194,6 @@ 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)
{