aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc/common/heart.c
diff options
context:
space:
mode:
Diffstat (limited to 'erts/etc/common/heart.c')
-rw-r--r--erts/etc/common/heart.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c
index c1f6551d21..70c2b3bb23 100644
--- a/erts/etc/common/heart.c
+++ b/erts/etc/common/heart.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1996-2009. All Rights Reserved.
+ * Copyright Ericsson AB 1996-2012. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -372,7 +372,8 @@ main(int argc, char **argv)
_setmode(erlin_fd,_O_BINARY);
_setmode(erlout_fd,_O_BINARY);
#endif
- strcpy(program_name, argv[0]);
+ strncpy(program_name, argv[0], sizeof(program_name));
+ program_name[sizeof(program_name)-1] = '\0';
notify_ack(erlout_fd);
cmd[0] = '\0';
do_terminate(message_loop(erlin_fd,erlout_fd));
@@ -682,14 +683,16 @@ do_terminate(reason)
print_error("Would reboot. Terminating.");
else {
kill_old_erlang();
- system(command);
+ /* suppress gcc warning with 'if' */
+ if(system(command));
print_error("Executed \"%s\". Terminating.",command);
}
free_env_val(command);
}
else {
kill_old_erlang();
- system((char*)&cmd[0]);
+ /* suppress gcc warning with 'if' */
+ if(system((char*)&cmd[0]));
print_error("Executed \"%s\". Terminating.",cmd);
}
}
@@ -724,12 +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);
- /* FIXME if s >= MSG_BODY_SIZE error */
+ /* if s >= MSG_BODY_SIZE, return a write
+ * failure immediately.
+ */
+ 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);