sudo_passwd_cleanup: Set auth->data to NULL after freeing.

GitHub issue #201
This commit is contained in:
Todd C. Miller
2022-11-17 08:10:35 -07:00
parent 0044893961
commit b3834bbf24

View File

@@ -117,11 +117,14 @@ sudo_passwd_verify(struct passwd *pw, const char *pass, sudo_auth *auth, struct
int
sudo_passwd_cleanup(struct passwd *pw, sudo_auth *auth, bool force)
{
char *pw_epasswd = auth->data;
debug_decl(sudo_passwd_cleanup, SUDOERS_DEBUG_AUTH);
if (pw_epasswd != NULL)
freezero(pw_epasswd, strlen(pw_epasswd));
if (auth->data != NULL) {
/* Zero out encrypted password before freeing. */
size_t len = strlen((char *)auth->data);
freezero(auth->data, len);
auth->data = NULL;
}
debug_return_int(AUTH_SUCCESS);
}