diff --git a/ompi/mpi/c/comm_get_name.c b/ompi/mpi/c/comm_get_name.c index e4e2a626a3..5b587e6f74 100644 --- a/ompi/mpi/c/comm_get_name.c +++ b/ompi/mpi/c/comm_get_name.c @@ -71,7 +71,7 @@ int MPI_Comm_get_name(MPI_Comm comm, char *name, int *length) able to completely fit into MPI_MAX_OBJECT_NAME bytes (i.e., name+\0). */ if ( comm->c_flags & OMPI_COMM_NAMEISSET ) { - strcpy(name, comm->c_name); + strncpy(name, comm->c_name, MPI_MAX_OBJECT_NAME); *length = (int) strlen(comm->c_name); } else { name[0] = '\0'; diff --git a/ompi/mpi/c/type_get_name.c b/ompi/mpi/c/type_get_name.c index 2e2c583c6a..64627e5624 100644 --- a/ompi/mpi/c/type_get_name.c +++ b/ompi/mpi/c/type_get_name.c @@ -67,6 +67,6 @@ int MPI_Type_get_name(MPI_Datatype type, char *type_name, int *resultlen) able to completely fit into MPI_MAX_OBJECT_NAME bytes (i.e., name+\0). */ *resultlen = (int)strlen(type->name); - strcpy(type_name, type->name); + strncpy(type_name, type->name, MPI_MAX_OBJECT_NAME); return MPI_SUCCESS; }