Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hydra: fix segfaults in argument parsing #5598

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/pm/hydra/ui/mpich/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ static char **config_argv = NULL;
static int reading_config_file = 0;
static struct HYD_arg_match_table match_table[];

#define ASSERT_ARGV \
do { \
if (!**argv) { \
status = HYD_FAILURE; \
HYDU_ERR_POP(status, "missing command line argument, add -h for help\n"); \
}\
} while (0)

static void init_ui_mpich_info(void)
{
HYD_ui_mpich_info.ppn = -1;
Expand Down Expand Up @@ -777,6 +785,7 @@ static HYD_status np_fn(char *arg, char ***argv)
status = get_current_exec(&exec);
HYDU_ERR_POP(status, "get_current_exec returned error\n");

ASSERT_ARGV;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea to make this a macro so it can be added to other argument parsing functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

status = HYDU_set_int(arg, &exec->proc_count, atoi(**argv));
HYDU_ERR_POP(status, "error getting executable process count\n");

Expand Down
4 changes: 4 additions & 0 deletions src/pm/hydra/utils/alloc/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ HYD_status HYDU_create_proxy_list(struct HYD_exec *exec_list, struct HYD_node *n
pg->proxy_list->next = NULL;
HYDU_free_proxy_list(pg->proxy_list);
pg->proxy_list = tmp;
if (pg->proxy_list == NULL) {
status = HYD_FAILURE;
HYDU_ERR_POP(status, "Missing executable.\n");
}
}
for (proxy = pg->proxy_list; proxy->next;) {
if (proxy->next->exec_list == NULL) {
Expand Down