From: Todd C. Miller Date: Sun, 22 Jul 2007 12:14:18 +0000 (+0000) Subject: Run cleanup code if the user hits ^C at the password prompt. X-Git-Tag: SUDO_1_7_0~471 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42ac4fb2cf571abf92d767b69447d6e396a33869;p=sudo Run cleanup code if the user hits ^C at the password prompt. --- diff --git a/auth/pam.c b/auth/pam.c index d6f5914f8..1c947d9dc 100644 --- a/auth/pam.c +++ b/auth/pam.c @@ -259,7 +259,7 @@ sudo_conv(num_msg, msg, response, appdata_ptr) if (pass == NULL) { /* We got ^C instead of a password; abort quickly. */ nil_pw = 1; - return(PAM_CONV_ERR); + goto err; } pr->resp = estrdup(pass); if (*pr->resp == '\0') @@ -278,20 +278,23 @@ sudo_conv(num_msg, msg, response, appdata_ptr) } break; default: - /* Zero and free allocated memory and return an error. */ - for (pr = *response, n = num_msg; n--; pr++) { - if (pr->resp != NULL) { - zero_bytes(pr->resp, strlen(pr->resp)); - free(pr->resp); - pr->resp = NULL; - } - } - zero_bytes(*response, num_msg * sizeof(struct pam_response)); - free(*response); - *response = NULL; - return(PAM_CONV_ERR); + goto err; } } return(PAM_SUCCESS); + +err: + /* Zero and free allocated memory and return an error. */ + for (pr = *response, n = num_msg; n--; pr++) { + if (pr->resp != NULL) { + zero_bytes(pr->resp, strlen(pr->resp)); + free(pr->resp); + pr->resp = NULL; + } + } + zero_bytes(*response, num_msg * sizeof(struct pam_response)); + free(*response); + *response = NULL; + return(PAM_CONV_ERR); }