Skip to content

Commit

Permalink
Handle NULL input when asking for group (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Lambers <[email protected]>
  • Loading branch information
marlam and Martin Lambers authored Oct 18, 2024
1 parent 5e8705d commit 147e2ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pam_weblogin.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
tty_output(pamh, str_printf(" [%d] %s", i+1, name));
}
char *group_input = tty_input(pamh, PROMPT_GROUP, PAM_PROMPT_ECHO_ON);
group = strtol(group_input, &end, 10);
if (!group_input)
{
errno = ERANGE; /* treat no input as invalid input */
} else
{
group = strtol(group_input, &end, 10);
}
free(group_input);
range_error = errno == ERANGE;
if (group < 1 || group > max_groups || range_error)
Expand Down

0 comments on commit 147e2ec

Please sign in to comment.