diff options
author | Sverker Eriksson <[email protected]> | 2016-04-13 15:18:13 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-04-13 15:26:42 +0200 |
commit | 97cdb6bd87f38b06ee477dbb17d4d2f7854b21e1 (patch) | |
tree | bbe978292aceb8c0223879c7208235d6a3c2b1bd /erts | |
parent | 5e1b5ef47f3f2b898d30e0425823835bd9a574d4 (diff) | |
download | otp-97cdb6bd87f38b06ee477dbb17d4d2f7854b21e1.tar.gz otp-97cdb6bd87f38b06ee477dbb17d4d2f7854b21e1.tar.bz2 otp-97cdb6bd87f38b06ee477dbb17d4d2f7854b21e1.zip |
erts: Fix bug in open_port with {args,ImproperList}
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/erl_bif_port.c | 2 | ||||
-rw-r--r-- | erts/emulator/test/port_SUITE.erl | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_bif_port.c b/erts/emulator/beam/erl_bif_port.c index 27c24197ea..e4d4559f48 100644 --- a/erts/emulator/beam/erl_bif_port.c +++ b/erts/emulator/beam/erl_bif_port.c @@ -953,6 +953,8 @@ static char **convert_args(Eterm l) } n = erts_list_length(l); + if (n < 0) + return NULL; /* We require at least one element in argv[0] + NULL at end */ pp = erts_alloc(ERTS_ALC_T_TMP, (n + 2) * sizeof(char **)); pp[i++] = erts_default_arg0; diff --git a/erts/emulator/test/port_SUITE.erl b/erts/emulator/test/port_SUITE.erl index 3d0509a28c..c0c0470c94 100644 --- a/erts/emulator/test/port_SUITE.erl +++ b/erts/emulator/test/port_SUITE.erl @@ -86,6 +86,7 @@ name1/1, t_binary/1, parallell/1, t_exit/1, env/1, bad_env/1, cd/1, exit_status/1, + bad_args/1, tps_16_bytes/1, tps_1K/1, line/1, stderr_to_stdout/1, otp_3906/1, otp_4389/1, win_massive/1, win_massive_client/1, mix_up_ports/1, otp_5112/1, otp_5119/1, otp_6224/1, @@ -112,6 +113,7 @@ all() -> {group, multiple_packets}, parallell, dying_port, port_program_with_path, open_input_file_port, open_output_file_port, name1, env, bad_env, cd, + bad_args, exit_status, iter_max_ports, t_exit, {group, tps}, line, stderr_to_stdout, otp_3906, otp_4389, win_massive, mix_up_ports, otp_5112, otp_5119, @@ -923,6 +925,23 @@ try_bad_env(Env) -> error:badarg -> ok end. +%% Test bad 'args' options. +bad_args(Config) when is_list(Config) -> + try_bad_args({args, [self()]}), + try_bad_args({args, ["head" | "tail"]}), + try_bad_args({args, ["head", "body" | "tail"]}), + try_bad_args({args, [<<"head">>, <<"body">> | <<"tail">>]}), + try_bad_args({args, not_a_list}), + try_bad_args({args, ["string",<<"binary">>, 1472, "string"]}), + try_bad_args({args, ["string",<<"binary">>], "element #3"}), + ok. + +try_bad_args(Args) -> + badarg = try open_port({spawn_executable,"ls"}, [Args]) + catch + error:badarg -> badarg + end. + %% 'cd' option %% (Can perhaps be made smaller by calling the other utility functions %% in this module.) |