Skip to content

Commit

Permalink
Merge branch 'john/erts/fix-heart-command-overflow/OTP-15034/ERIERL-1…
Browse files Browse the repository at this point in the history
…66' into maint-20

* john/erts/fix-heart-command-overflow/OTP-15034/ERIERL-166:
  heart: Use ntohs instead of manual conversion

# Conflicts:
#	lib/kernel/test/heart_SUITE.erl
  • Loading branch information
Erlang/OTP committed May 2, 2018
2 parents f2c1d53 + 05b1c13 commit 6faad4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 1 addition & 4 deletions erts/etc/common/heart.c
Expand Up @@ -825,11 +825,8 @@ write_message(fd, mp)
int fd;
struct msg *mp;
{
int len;
char* tmp;
int len = ntohs(mp->len);

tmp = (char*) &(mp->len);
len = (*tmp * 256) + *(tmp+1);
if ((len == 0) || (len > MSG_BODY_SIZE)) {
return MSG_HDR_SIZE;
} /* cc68k wants (char *) */
Expand Down
13 changes: 10 additions & 3 deletions lib/kernel/test/heart_SUITE.erl
Expand Up @@ -346,9 +346,16 @@ clear_cmd(Config) when is_list(Config) ->

get_cmd(Config) when is_list(Config) ->
{ok, Node} = start_check(slave, ?UNIQ_NODE_NAME),
Cmd = "test",
ok = rpc:call(Node, heart, set_cmd, [Cmd]),
{ok, Cmd} = rpc:call(Node, heart, get_cmd, []),

ShortCmd = "test",
ok = rpc:call(Node, heart, set_cmd, [ShortCmd]),
{ok, ShortCmd} = rpc:call(Node, heart, get_cmd, []),

%% This would hang prior to OTP-15024 being fixed.
LongCmd = [$a || _ <- lists:seq(1, 160)],
ok = rpc:call(Node, heart, set_cmd, [LongCmd]),
{ok, LongCmd} = rpc:call(Node, heart, get_cmd, []),

stop_node(Node),
ok.

Expand Down

0 comments on commit 6faad4d

Please sign in to comment.