1010 * Copyright (c) 2016      Intel, Inc. All rights reserved. 
1111 * Copyright (c) 2016      Research Organization for Information Science 
1212 *                         and Technology (RIST). All rights reserved. 
13+  * Copyright (c) 2023      NVIDIA Corporation. All rights reserved. 
14+  * Copyright (c) 2023      Jeffrey M. Squyres.  All rights reserved. 
1315 * $COPYRIGHT$ 
1416 * 
1517 * Additional copyrights may follow 
@@ -682,8 +684,18 @@ static int rebuild_communicator_list (mqs_process *proc)
682684                                    p_info  );
683685            old -> group  =  find_or_create_group ( proc , group_base  );
684686        }
685-         mqs_fetch_data ( proc , comm_ptr  +  i_info -> ompi_communicator_t .offset .c_name ,
686-                         64 , old -> comm_info .name  );
687+         mqs_taddr_t  name_addr  =  ompi_fetch_pointer ( proc ,
688+                                                     comm_ptr  +  i_info -> ompi_communicator_t .offset .c_name ,
689+                                                     p_info  );
690+         /* c_name can be up to MPI_MAX_OBJECT_NAME bytes, but we only 
691+          * copy the first (sizeof(old->comm_info.name)-1) here.  Make 
692+          * sure the string is correctly terminated. */ 
693+         size_t  target_size  =  sizeof (old -> comm_info .name );
694+         mqs_fetch_data ( proc , name_addr , target_size , old -> comm_info .name  );
695+         old -> comm_info .name [target_size  -  1 ] =  '\0' ;
696+         /* Defensively zero anything beyond the actual name */ 
697+         size_t  src_strlen  =  strlen (old -> comm_info .name );
698+         memset (old -> comm_info .name  +  src_strlen , 0 , target_size  -  1  -  src_strlen );
687699
688700        if ( NULL  !=  old -> group  ) {
689701            old -> comm_info .size  =  old -> group -> entries ;
@@ -1156,8 +1168,9 @@ static int fetch_request( mqs_process *proc, mpi_process_info *p_info,
11561168                               ompi_datatype  +  i_info -> ompi_datatype_t .offset .size ,
11571169                               p_info  );
11581170        /* Be user friendly, show the datatype name */ 
1171+         size_t  data_name_size  =  sizeof (data_name );
11591172        mqs_fetch_data ( proc , ompi_datatype  +  i_info -> ompi_datatype_t .offset .name ,
1160-                         64 , data_name  );
1173+                         data_name_size , data_name  );
11611174        if ( '\0'  !=  data_name [0 ] ) {
11621175            // res->extra_text[x] is only 64 chars long -- same as 
11631176            // data_name.  If you try to snprintf it into 
@@ -1171,6 +1184,11 @@ static int fetch_request( mqs_process *proc, mpi_process_info *p_info,
11711184                      (int )res -> desired_length );
11721185            snprintf ( (char * )res -> extra_text [2 ], 64 , "%s" ,
11731186                      data_name  );
1187+         } else  {
1188+             data_name [data_name_size  -  1 ] =  '\0' ;
1189+             /* Be nice and zero anything beyond the actual name */ 
1190+             size_t  data_name_strlen  =  strlen (data_name );
1191+             memset (data_name  +  data_name_strlen , 0 , data_name_size  -  1  -  data_name_strlen );
11741192        }
11751193        /* And now compute the real length as specified by the user */ 
11761194        res -> desired_length  *=
0 commit comments