aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-09-13 11:26:23 +0200
committerPatrik Nyblom <[email protected]>2010-09-13 11:26:23 +0200
commitbbf3ab21b404aedbf9c7b7062b1e96062133fe44 (patch)
tree8b1c92bf4026ac89bb5e53487fd33165852d271a /lib/kernel
parent9c563c44bb4a7aeabb737ddf4dca5d6639502397 (diff)
parent2f2d592385b53ce594623a614c2e0cd8e2107d7d (diff)
downloadotp-bbf3ab21b404aedbf9c7b7062b1e96062133fe44.tar.gz
otp-bbf3ab21b404aedbf9c7b7062b1e96062133fe44.tar.bz2
otp-bbf3ab21b404aedbf9c7b7062b1e96062133fe44.zip
Merge branch 'pan/epmd-vulnerabilities/OTP-8780' into dev
* pan/epmd-vulnerabilities/OTP-8780: Teach testcases to survive TIME_WAIT overload Update erl_interface doc and testsuite for epmd changes Restore null termination of input buffer Teach testcase epmd_SUITE:too_large to accept econnaborted Teach epmd_cli.c to not respond 'Killed' when killing denied Calculate minimal packet size for ALIVE2 requests correctly Document epmd and it's options properly and fixup help text Fix anomalies in epmd not yet reported as security issues Remove two buffer overflow vulnerabilities in EPMD Remove all support for ancient EPMD protocol Remove very old protocol from EPMD Conflicts: lib/erl_interface/src/epmd/epmd_port.c
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/erl_epmd.erl86
-rw-r--r--lib/kernel/src/erl_epmd.hrl17
2 files changed, 9 insertions, 94 deletions
diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl
index 4a22637304..91af49f303 100644
--- a/lib/kernel/src/erl_epmd.erl
+++ b/lib/kernel/src/erl_epmd.erl
@@ -210,19 +210,6 @@ open({A,B,C,D,E,F,G,H}=EpmdAddr, Timeout) when ?ip6(A,B,C,D,E,F,G,H) ->
close(Socket) ->
gen_tcp:close(Socket).
-
-do_register_node_v0(NodeName, TcpPort) ->
- case open() of
- {ok, Socket} ->
- Name = cstring(NodeName),
- Len = 1+2+length(Name),
- gen_tcp:send(Socket, [?int16(Len), ?EPMD_ALIVE,
- ?int16(TcpPort), Name]),
- wait_for_reg_reply_v0(Socket, []);
- Error ->
- Error
- end.
-
do_register_node(NodeName, TcpPort) ->
case open() of
{ok, Socket} ->
@@ -240,14 +227,7 @@ do_register_node(NodeName, TcpPort) ->
Name,
?int16(Elen),
Extra]),
- case wait_for_reg_reply(Socket, []) of
- {error, epmd_close} ->
- %% could be old epmd; try old protocol
-% erlang:display('trying old'),
- do_register_node_v0(NodeName, TcpPort);
- Other ->
- Other
- end;
+ wait_for_reg_reply(Socket, []);
Error ->
Error
end.
@@ -305,41 +285,9 @@ wait_for_reg_reply(Socket, SoFar) ->
{error, no_reg_reply_from_epmd}
end.
-wait_for_reg_reply_v0(Socket, SoFar) ->
- receive
- {tcp, Socket, Data0} ->
- case SoFar ++ Data0 of
- [$Y, A, B] ->
- {alive, Socket, ?u16(A, B)};
- Data when length(Data) < 3 ->
- wait_for_reg_reply(Socket, Data);
- Garbage ->
- {error, {garbage_from_epmd, Garbage}}
- end;
- {tcp_closed, Socket} ->
- {error, duplicate_name} % A guess -- the most likely reason.
- after 10000 ->
- gen_tcp:close(Socket),
- {error, no_reg_reply_from_epmd}
- end.
%%
%% Lookup a node "Name" at Host
%%
-get_port_v0(Node, EpmdAddress) ->
- case open(EpmdAddress) of
- {ok, Socket} ->
- Name = cstring(Node),
- Len = 1+length(Name),
- gen_tcp:send(Socket, [?int16(Len),?EPMD_PORT_PLEASE, Name]),
- wait_for_port_reply_v0(Socket, []);
- _Error ->
- ?port_please_failure(),
- noport
- end.
-
-%%% Not used anymore
-%%% get_port(Node, EpmdAddress) ->
-%%% get_port(Node, EpmdAddress, infinity).
get_port(Node, EpmdAddress, Timeout) ->
case open(EpmdAddress, Timeout) of
@@ -347,40 +295,12 @@ get_port(Node, EpmdAddress, Timeout) ->
Name = to_string(Node),
Len = 1+length(Name),
gen_tcp:send(Socket, [?int16(Len),?EPMD_PORT_PLEASE2_REQ, Name]),
- Reply = wait_for_port_reply(Socket, []),
- case Reply of
- closed ->
- get_port_v0(Node, EpmdAddress);
- Other ->
- Other
- end;
+ wait_for_port_reply(Socket, []);
_Error ->
?port_please_failure2(_Error),
noport
end.
-wait_for_port_reply_v0(Socket, SoFar) ->
- receive
- {tcp, Socket, Data0} ->
-% io:format("got ~p~n", [Data0]),
- case SoFar ++ Data0 of
- [A, B] ->
- wait_for_close(Socket, {port, ?u16(A, B), 0});
-% wait_for_close(Socket, {port, ?u16(A, B)});
- Data when length(Data) < 2 ->
- wait_for_port_reply_v0(Socket, Data);
- Garbage ->
- ?port_please_failure(),
- {error, {garbage_from_epmd, Garbage}}
- end;
- {tcp_closed, Socket} ->
- ?port_please_failure(),
- noport
- after 10000 ->
- ?port_please_failure(),
- gen_tcp:close(Socket),
- noport
- end.
wait_for_port_reply(Socket, SoFar) ->
receive
@@ -487,8 +407,6 @@ wait_for_close(Socket, Reply) ->
%%
%% Creates a (flat) null terminated string from atom or list.
%%
-cstring(S) when is_atom(S) -> cstring(atom_to_list(S));
-cstring(S) when is_list(S) -> S ++ [0].
to_string(S) when is_atom(S) -> atom_to_list(S);
to_string(S) when is_list(S) -> S.
diff --git a/lib/kernel/src/erl_epmd.hrl b/lib/kernel/src/erl_epmd.hrl
index 47ab6195d8..5a50fda508 100644
--- a/lib/kernel/src/erl_epmd.hrl
+++ b/lib/kernel/src/erl_epmd.hrl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -17,16 +17,13 @@
%% %CopyrightEnd%
%%
--define(EPMD_ALIVE, $a).
--define(EPMD_PORT_PLEASE, $p).
--define(EPMD_NAMES, $n).
--define(EPMD_DUMP, $d).
--define(EPMD_KILL, $k).
--define(EPMD_STOP, $s).
-
--define(EPMD_ALIVE_OK, $Y).
-
-define(EPMD_ALIVE2_REQ, $x).
-define(EPMD_PORT_PLEASE2_REQ, $z).
-define(EPMD_ALIVE2_RESP, $y).
-define(EPMD_PORT2_RESP, $w).
+-define(EPMD_NAMES, $n).
+
+%% Commands used only by interactive client
+-define(EPMD_DUMP, $d).
+-define(EPMD_KILL, $k).
+-define(EPMD_STOP, $s).