From fa8456a96f099b4aa878b6cea7e3fef0e6da1e63 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Tue, 5 Apr 2011 20:45:17 -0400 Subject: heart: remove garbage appended to heart command heart:get_cmd/0 is documented to return an empty string if the command is cleared. get_cmd/0 returns 2 extra bytes: 1 byte for the trailing null, 1 byte from the op (the op is an unsigned char and 2 bytes are allocated for it in the returned buffer). 1> heart:get_cmd(). {ok,[0,0]} 2> heart:set_cmd("echo hello"). ok 3> heart:get_cmd(). {ok,[101,99,104,111,32,104,101,108,108,111,0,0]} 4> heart:clear_cmd(). ok 5> heart:get_cmd(). {ok,[0,99]} --- erts/etc/common/heart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'erts') diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c index 778b3569c7..7a5746e630 100644 --- a/erts/etc/common/heart.c +++ b/erts/etc/common/heart.c @@ -727,16 +727,16 @@ static int heart_cmd_reply(int fd, char *s) { struct msg m; - int len = strlen(s) + 1; /* Include \0 */ + int len = strlen(s); /* if s >= MSG_BODY_SIZE, return a write * failure immediately. */ - if (len > sizeof(m.fill)) + if (len >= sizeof(m.fill)) return -1; m.op = HEART_CMD; - m.len = htons(len + 2); /* Include Op */ + m.len = htons(len + 1); /* Include Op */ strcpy((char*)m.fill, s); return write_message(fd, &m); -- cgit v1.2.3