From: Arnaud Giersch Date: Fri, 1 Jun 2018 13:27:12 +0000 (+0200) Subject: Ensure that the terminating nul byte is also copied. X-Git-Tag: v3.20~172 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/44814aa98b9528984d327d2678dc3b59e0a3fcee Ensure that the terminating nul byte is also copied. --- 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';