]> granicus.if.org Git - sudo/commitdiff
Run cleanup code if the user hits ^C at the password prompt.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 22 Jul 2007 12:14:18 +0000 (12:14 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 22 Jul 2007 12:14:18 +0000 (12:14 +0000)
auth/pam.c

index d6f5914f80e055a1d20a7fca529492f496e463a6..1c947d9dc6eacd38b10fba5335ccd9db96b98f88 100644 (file)
@@ -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);
 }