Skip to content

Commit c5de3ca

Browse files
authored
Merge pull request #10917 from drwootton/coverity_bug_1515829
Fix 1 byte overlay in comm_method_string: Coverity CID 1515829
2 parents c95d9aa + 3fcad0e commit c5de3ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ompi/mca/hook/comm_method/hook_comm_method_fns.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ comm_method_string(MPI_Comm comm, int rank, int *comm_mode) {
126126
else {
127127
/* Determine how much memory is needed to store UCX transport info */
128128
char *s = UCX_TAG;
129-
name_length = strlen(s);
129+
/* Allocate storage to store UCX transport info, accounting for
130+
* trailing '\0' in UCX_TAG and ',' and ';' delimiting each transport string
131+
* then build the info string */
132+
name_length = strlen(s) + 1;
130133
for (i = 0; i < transports->count; i++) {
131134
name_length = name_length + strlen(transports->entries[i].transport_name) +
132135
strlen(transports->entries[i].device_name) + 2;
133136
}
134-
/* Allocate storage to store UCX transport info then build the info string */
135137
string = malloc(name_length);
136138
if (!string) {
137139
return NULL;

0 commit comments

Comments
 (0)