From 147e2eced81a9079d180be9c876c27d3b28cb9ac Mon Sep 17 00:00:00 2001 From: Martin Lambers Date: Fri, 18 Oct 2024 11:11:31 +0200 Subject: [PATCH] Handle NULL input when asking for group (#104) Co-authored-by: Martin Lambers --- src/pam_weblogin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pam_weblogin.c b/src/pam_weblogin.c index 64fccec..6dc6dbc 100644 --- a/src/pam_weblogin.c +++ b/src/pam_weblogin.c @@ -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)