aboutsummaryrefslogtreecommitdiffstats
path: root/erts/test/erlc_SUITE.erl
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2010-10-01 19:55:17 -0400
committerBjörn Gustavsson <[email protected]>2010-10-04 15:25:22 +0200
commitbe8759e68b337524c056b8bb757ea68c9996d863 (patch)
treeb769fd3390d8cb8b0144479eecae033674b90be9 /erts/test/erlc_SUITE.erl
parent3d430d0faa33f7d74f1258b400515dc6cea40c4e (diff)
downloadotp-be8759e68b337524c056b8bb757ea68c9996d863.tar.gz
otp-be8759e68b337524c056b8bb757ea68c9996d863.tar.bz2
otp-be8759e68b337524c056b8bb757ea68c9996d863.zip
erlc: prevent buffer overflows
Check buffer operations and increase the size of the buffer used for holding command line arguments, since the "-D" switch will be expanded into 3 arguments when passed to erl.
Diffstat (limited to 'erts/test/erlc_SUITE.erl')
-rw-r--r--erts/test/erlc_SUITE.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/erts/test/erlc_SUITE.erl b/erts/test/erlc_SUITE.erl
index 437f020f99..4797f78be2 100644
--- a/erts/test/erlc_SUITE.erl
+++ b/erts/test/erlc_SUITE.erl
@@ -21,13 +21,13 @@
%% Tests the erlc command by compiling various types of files.
-export([all/1, compile_erl/1, compile_yecc/1, compile_script/1,
- compile_mib/1, good_citizen/1, deep_cwd/1]).
+ compile_mib/1, good_citizen/1, deep_cwd/1, arg_overflow/1]).
-include_lib("test_server/include/test_server.hrl").
all(suite) ->
[compile_erl, compile_yecc, compile_script, compile_mib,
- good_citizen, deep_cwd].
+ good_citizen, deep_cwd, arg_overflow].
%% Copy from erlc_SUITE_data/include/erl_test.hrl.
@@ -189,6 +189,18 @@ deep_cwd_1(PrivDir) ->
?line true = filelib:is_file("test.beam"),
ok.
+%% Test that a large number of command line switches does not
+%% overflow the argument buffer
+arg_overflow(Config) when is_list(Config) ->
+ ?line {SrcDir, _OutDir, Cmd} = get_cmd(Config),
+ ?line FileName = filename:join(SrcDir, "erl_test_ok.erl"),
+ ?line Args = lists:flatten([ ["-D", integer_to_list(N), "=1 "] ||
+ N <- lists:seq(1,10000) ]),
+ ?line run(Config, Cmd, FileName, Args,
+ ["Warning: function foo/0 is unused\$",
+ "_OK_"]),
+ ok.
+
erlc() ->
case os:find_executable("erlc") of
false ->