diff --git a/src/plugins/mpi/pmi2/info.c b/src/plugins/mpi/pmi2/info.c index 8c9dbfef23e074932620f43d36f0c8b4c775a751..459485d8065482a72f5e5f520681a68696b9df5f 100644 --- a/src/plugins/mpi/pmi2/info.c +++ b/src/plugins/mpi/pmi2/info.c @@ -84,7 +84,7 @@ enqueue_nag_req(int fd, int rank, char *key) req = xmalloc(sizeof(nag_req_t)); req->fd = fd; req->rank = rank; - strncpy(req->key, key, PMI2_MAX_KEYLEN); + strncpy(req->key, key, (PMI2_MAX_KEYLEN - 1)); /* Insure NULL at end */ /* insert in the head */ req->next = nag_req_list; diff --git a/src/plugins/proctrack/linuxproc/kill_tree.c b/src/plugins/proctrack/linuxproc/kill_tree.c index dd48a1c600c123ae97d03e665f2bda6adeb3655c..48dac22790a6a842b2acaf3240cea266c9696d53 100644 --- a/src/plugins/proctrack/linuxproc/kill_tree.c +++ b/src/plugins/proctrack/linuxproc/kill_tree.c @@ -332,7 +332,7 @@ extern pid_t find_ancestor(pid_t process, char *process_name) int fd; long pid, ppid; - rbuf = xmalloc(4096); + rbuf = xmalloc_nz(4096); pid = ppid = (long)process; do { if (ppid <= 1) { @@ -345,6 +345,7 @@ extern pid_t find_ancestor(pid_t process, char *process_name) pid = 0; break; } + memset(rbuf, 0, 4096); buf_used = read(fd, rbuf, 4096); if ((buf_used <= 0) || (buf_used >= 4096)) { close(fd); diff --git a/src/plugins/task/affinity/cpuset.c b/src/plugins/task/affinity/cpuset.c index 219e46db96d989434a22024b3a5ab579808ecb05..1af5b2ffc97898dd56bc981e80f027dd45a8568c 100644 --- a/src/plugins/task/affinity/cpuset.c +++ b/src/plugins/task/affinity/cpuset.c @@ -230,12 +230,12 @@ int slurm_set_cpuset(char *base, char *path, pid_t pid, size_t size, * "mems" must be set before any tasks can be added. */ snprintf(file_path, sizeof(file_path), "%s/%smems", base, cpuset_prefix); - memset(mstr, 0, sizeof(mstr)); fd = open(file_path, O_RDONLY); if (fd < 0) { error("open(%s): %m", file_path); } else { - rc = read(fd, mstr, sizeof(mstr)); + memset(mstr, 0, sizeof(mstr)); + rc = read(fd, mstr, sizeof(mstr)-1); /* Insure NULL at end */ close(fd); if (rc < 1) { error("read(%s): %m", file_path); @@ -306,7 +306,8 @@ int slurm_get_cpuset(char *path, pid_t pid, size_t size, cpu_set_t *mask) error("open(%s): %m", file_path); return SLURM_ERROR; } - rc = read(fd, mstr, sizeof(mstr)); + memset(mstr, 0, sizeof(mstr)); + rc = read(fd, mstr, sizeof(mstr)-1); /* Insure NULL at end */ close(fd); if (rc < 1) { error("read(%s): %m", file_path);