Skip to content

Commit 65df29a

Browse files
committed
Fix bad dereferences when passed a NULL parameter to PMIx_Init
Missed a couple of spots that reference the "proc" parameter in PMIx_Init, which is allowed to be NULL. Use a different place to get the desired data and avoid the issue. Thanks to @krempel-pt for the report. Signed-off-by: Ralph Castain <[email protected]>
1 parent 1491f3e commit 65df29a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/client/pmix_client.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
579579
* rank should be known. So return them here if
580580
* requested */
581581
if (NULL != proc) {
582-
pmix_strncpy(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN);
583-
proc->rank = pmix_globals.myid.rank;
582+
PMIX_LOAD_PROCID(proc, pmix_globals.myid.nspace, pmix_globals.myid.rank);
584583
}
585584
++pmix_globals.init_cntr;
586585
/* we also need to check the info keys to see if something need
@@ -705,7 +704,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
705704
PMIX_CONSTRUCT(&pmix_server_globals.iof_residuals, pmix_list_t);
706705
} else {
707706
if (NULL != proc) {
708-
pmix_strncpy(proc->nspace, evar, PMIX_MAX_NSLEN);
707+
PMIX_LOAD_NSPACE(proc->nspace, evar);
709708
}
710709
PMIX_LOAD_NSPACE(pmix_globals.myid.nspace, evar);
711710
/* set the global pmix_namespace_t object for our peer */
@@ -732,10 +731,10 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
732731
PMIX_RELEASE_THREAD(&pmix_global_lock);
733732
return PMIX_ERR_NOMEM;
734733
}
735-
pmix_globals.mypeer->info->pname.nspace = strdup(proc->nspace);
736-
pmix_globals.mypeer->info->pname.rank = proc->rank;
737-
PMIX_LOAD_PROCID(pmix_globals.myidval.data.proc, proc->nspace, proc->rank);
738-
pmix_globals.myrankval.data.rank = proc->rank;
734+
pmix_globals.mypeer->info->pname.nspace = strdup(pmix_globals.myid.nspace);
735+
pmix_globals.mypeer->info->pname.rank = pmix_globals.myid.rank;
736+
PMIX_LOAD_PROCID(pmix_globals.myidval.data.proc, pmix_globals.myid.nspace, pmix_globals.myid.rank);
737+
pmix_globals.myrankval.data.rank = pmix_globals.myid.rank;
739738

740739
/* select our psec compat module - the selection will be based
741740
* on the corresponding envars that should have been passed

0 commit comments

Comments
 (0)