aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/dist_util.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-05-23 15:06:04 +0200
committerLukas Larsson <[email protected]>2017-05-23 15:06:04 +0200
commit2fa8ade78ef987ad1f3ab42bed691ebfcf29d29d (patch)
tree29a61181f6c6231235608f99c0651cffbbf34e96 /lib/kernel/src/dist_util.erl
parent24481c66a615c62b22d664e141b581b979af0eaf (diff)
downloadotp-2fa8ade78ef987ad1f3ab42bed691ebfcf29d29d.tar.gz
otp-2fa8ade78ef987ad1f3ab42bed691ebfcf29d29d.tar.bz2
otp-2fa8ade78ef987ad1f3ab42bed691ebfcf29d29d.zip
kernel: Add early reject of invalid node names
Diffstat (limited to 'lib/kernel/src/dist_util.erl')
-rw-r--r--lib/kernel/src/dist_util.erl19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/kernel/src/dist_util.erl b/lib/kernel/src/dist_util.erl
index 1c326afca8..b3507e5d13 100644
--- a/lib/kernel/src/dist_util.erl
+++ b/lib/kernel/src/dist_util.erl
@@ -572,12 +572,25 @@ recv_name(#hs_data{socket = Socket, f_recv = Recv}) ->
?shutdown(no_node)
end.
-get_name([$n,VersionA, VersionB, Flag1, Flag2, Flag3, Flag4 | OtherNode]) ->
- {?u32(Flag1, Flag2, Flag3, Flag4), list_to_atom(OtherNode),
- ?u16(VersionA,VersionB)};
+get_name([$n,VersionA, VersionB, Flag1, Flag2, Flag3, Flag4 | OtherNode] = Data) ->
+ case is_valid_name(OtherNode) of
+ true ->
+ {?u32(Flag1, Flag2, Flag3, Flag4), list_to_atom(OtherNode),
+ ?u16(VersionA,VersionB)};
+ false ->
+ ?shutdown(Data)
+ end;
get_name(Data) ->
?shutdown(Data).
+is_valid_name(OtherNodeName) ->
+ case string:lexemes(OtherNodeName,"@") of
+ [_OtherNodeName,_OtherNodeHost] ->
+ true;
+ _else ->
+ false
+ end.
+
publish_type(Flags) ->
case Flags band ?DFLAG_PUBLISHED of
0 ->