Skip to content

Commit

Permalink
Fix bad dereferences when passed a NULL parameter to PMIx_Init
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rhc54 committed Aug 23, 2022
1 parent 1491f3e commit 65df29a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/client/pmix_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
* rank should be known. So return them here if
* requested */
if (NULL != proc) {
pmix_strncpy(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN);
proc->rank = pmix_globals.myid.rank;
PMIX_LOAD_PROCID(proc, pmix_globals.myid.nspace, pmix_globals.myid.rank);
}
++pmix_globals.init_cntr;
/* we also need to check the info keys to see if something need
Expand Down Expand Up @@ -705,7 +704,7 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
PMIX_CONSTRUCT(&pmix_server_globals.iof_residuals, pmix_list_t);
} else {
if (NULL != proc) {
pmix_strncpy(proc->nspace, evar, PMIX_MAX_NSLEN);
PMIX_LOAD_NSPACE(proc->nspace, evar);
}
PMIX_LOAD_NSPACE(pmix_globals.myid.nspace, evar);
/* set the global pmix_namespace_t object for our peer */
Expand All @@ -732,10 +731,10 @@ PMIX_EXPORT pmix_status_t PMIx_Init(pmix_proc_t *proc, pmix_info_t info[], size_
PMIX_RELEASE_THREAD(&pmix_global_lock);
return PMIX_ERR_NOMEM;
}
pmix_globals.mypeer->info->pname.nspace = strdup(proc->nspace);
pmix_globals.mypeer->info->pname.rank = proc->rank;
PMIX_LOAD_PROCID(pmix_globals.myidval.data.proc, proc->nspace, proc->rank);
pmix_globals.myrankval.data.rank = proc->rank;
pmix_globals.mypeer->info->pname.nspace = strdup(pmix_globals.myid.nspace);
pmix_globals.mypeer->info->pname.rank = pmix_globals.myid.rank;
PMIX_LOAD_PROCID(pmix_globals.myidval.data.proc, pmix_globals.myid.nspace, pmix_globals.myid.rank);
pmix_globals.myrankval.data.rank = pmix_globals.myid.rank;

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

0 comments on commit 65df29a

Please sign in to comment.