LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0437-Do-not-allow-an-empty-string-as-node-name.patch of Package erlang (Project home:Ledest:erlang:20)

From 824bf7f84f8d9fdca0c5e6e752a1c80566b99a9d Mon Sep 17 00:00:00 2001
From: Richard Carlsson <richardc@klarna.com>
Date: Mon, 8 Oct 2018 14:56:20 +0200
Subject: [PATCH] Do not allow an empty string as node name

Passing -sname '' or -sname '@bar' to erl would result in an obscure
error message "Protocol 'inet_tcp': register/listen error: epmd_close"
because the check for valid names did not disallow the empty string.
---
 lib/kernel/src/net_kernel.erl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl
index 3cf11fd7b1..01d809b566 100644
--- a/lib/kernel/src/net_kernel.erl
+++ b/lib/kernel/src/net_kernel.erl
@@ -1432,7 +1432,7 @@ validate_hostname([$@|HostPart] = Host) ->
     end.
 
 valid_name_head(Head) ->
-    {ok, MP} = re:compile("^[0-9A-Za-z_\\-]*$", [unicode]),
+    {ok, MP} = re:compile("^[0-9A-Za-z_\\-]+$", [unicode]),
         case re:run(Head, MP) of
             {match, _} ->
                 true;
-- 
2.16.4