aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_mtrace.c
diff options
context:
space:
mode:
authorDeepak Goel <[email protected]>2017-02-15 15:13:38 -0800
committerDeepak Goel <[email protected]>2017-03-22 15:42:22 -0700
commit3fcf58b142e22adb754b312576570c904655f877 (patch)
tree5e0630d7ca5b6544f2d1db3c66b2a26a70f2f85e /erts/emulator/beam/erl_mtrace.c
parentaa315e1cf1b79ab782e5b4c944595495ebf4e2f4 (diff)
downloadotp-3fcf58b142e22adb754b312576570c904655f877.tar.gz
otp-3fcf58b142e22adb754b312576570c904655f877.tar.bz2
otp-3fcf58b142e22adb754b312576570c904655f877.zip
This patch fixes the issue in which erlang fails to start
if the hostname is 64 characters on a linux system.
Diffstat (limited to 'erts/emulator/beam/erl_mtrace.c')
-rw-r--r--erts/emulator/beam/erl_mtrace.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_mtrace.c b/erts/emulator/beam/erl_mtrace.c
index e275867928..bb6f8660f1 100644
--- a/erts/emulator/beam/erl_mtrace.c
+++ b/erts/emulator/beam/erl_mtrace.c
@@ -572,7 +572,7 @@ void erts_mtrace_pre_init(void)
void erts_mtrace_init(char *receiver, char *nodename)
{
- char hostname[MAXHOSTNAMELEN];
+ char hostname[MAXHOSTNAMELEN + 1];
char pid[21]; /* enough for a 64 bit number */
socket_desc = ERTS_SOCK_INVALID_SOCKET;
@@ -613,9 +613,10 @@ void erts_mtrace_init(char *receiver, char *nodename)
}
tracep = trace_buffer;
endp = trace_buffer + TRACE_BUF_SZ;
- if (erts_sock_gethostname(hostname, MAXHOSTNAMELEN) != 0)
+ /* gethostname requires that the len is max(hostname) + 1 */
+ if (erts_sock_gethostname(hostname, MAXHOSTNAMELEN + 1) != 0)
hostname[0] = '\0';
- hostname[MAXHOSTNAMELEN-1] = '\0';
+ hostname[MAXHOSTNAMELEN] = '\0';
sys_get_pid(pid, sizeof(pid));
write_trace_header(nodename ? nodename : "", pid, hostname);
erts_mtrace_update_heap_size();