From 44814aa98b9528984d327d2678dc3b59e0a3fcee Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 1 Jun 2018 15:27:12 +0200 Subject: [PATCH] Ensure that the terminating nul byte is also copied. --- src/smpi/mpi/smpi_comm.cpp | 2 +- src/xbt/backtrace_linux.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index 98a41c88b3..58dd774e0f 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -120,7 +120,7 @@ void Comm::get_name (char* name, int* len) return; } if(this == MPI_COMM_WORLD) { - strncpy(name, "WORLD",5); + strncpy(name, "WORLD", 6); *len = 5; } else { *len = snprintf(name, MPI_MAX_NAME_STRING, "%p", this); diff --git a/src/xbt/backtrace_linux.cpp b/src/xbt/backtrace_linux.cpp index abedb8190a..5df45b93ba 100644 --- a/src/xbt/backtrace_linux.cpp +++ b/src/xbt/backtrace_linux.cpp @@ -200,7 +200,7 @@ std::vector resolveBacktrace( line_func[strlen(line_func) - 1] = '\0'; } else { XBT_VERB("Cannot run fgets to look for symbol %zu, addr %s", i, addrs[i].c_str()); - strncpy(line_func, "???",3); + strncpy(line_func, "???", 4); } if (fgets(line_pos, 1024, pipe)) { line_pos[strlen(line_pos) - 1] = '\0'; @@ -295,7 +295,7 @@ std::vector resolveBacktrace( line_func[strlen(line_func) - 1] = '\0'; } else { XBT_VERB("Cannot read result of subcommand %s", subcmd.c_str()); - strncpy(line_func, "???",3); + strncpy(line_func, "???", 4); } if (fgets(line_pos, 1024, subpipe)) { line_pos[strlen(line_pos) - 1] = '\0'; -- 2.20.1