From: Todd C. Miller Date: Tue, 14 Jul 2015 20:00:18 +0000 (-0600) Subject: Add warning if calloc() fails. X-Git-Tag: SUDO_1_8_14^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7187c19c839b44f70eb771e24a6aad39f1e0aab8;p=sudo Add warning if calloc() fails. Add debugging for other unexpected errors. --- diff --git a/plugins/sudoers/auth/pam.c b/plugins/sudoers/auth/pam.c index 571dbf824..5e96959cd 100644 --- a/plugins/sudoers/auth/pam.c +++ b/plugins/sudoers/auth/pam.c @@ -320,11 +320,16 @@ converse(int num_msg, PAM_CONST struct pam_message **msg, int ret = PAM_SUCCESS; debug_decl(converse, SUDOERS_DEBUG_AUTH) - if (num_msg <= 0 || num_msg > PAM_MAX_NUM_MSG) + if (num_msg <= 0 || num_msg > PAM_MAX_NUM_MSG) { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, + "invalid number of PAM messages: %d", num_msg); debug_return_int(PAM_CONV_ERR); + } - if ((*response = calloc(num_msg, sizeof(struct pam_response))) == NULL) + if ((*response = calloc(num_msg, sizeof(struct pam_response))) == NULL) { + sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); debug_return_int(PAM_BUF_ERR); + } for (pr = *response, pm = *msg, n = num_msg; n--; pr++, pm++) { type = SUDO_CONV_PROMPT_ECHO_OFF; @@ -364,6 +369,8 @@ converse(int num_msg, PAM_CONST struct pam_message **msg, goto done; } if (strlen(pass) >= PAM_MAX_RESP_SIZE) { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO, + "password longer than %d", PAM_MAX_RESP_SIZE); ret = PAM_CONV_ERR; goto done; }