2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 22:05:46 +00:00

Avoid a double free when ipa_hostname is set in sssd.conf and it

is an unqualified host name.  From Daniel Kopecek.

Also move the "unable to allocate memory" warning into get_ipa_hostname()
itself to make it easier to see where the allocation failed in the
debug log.
This commit is contained in:
Todd C. Miller
2017-11-28 11:28:44 -07:00
parent 250209d7a8
commit 93828eca65

View File

@@ -349,6 +349,8 @@ get_ipa_hostname(char **shostp, char **lhostp)
*lhostp = lhost;
ret = true;
} else {
sudo_warnx(U_("%s: %s"), __func__,
U_("unable to allocate memory"));
free(shost);
free(lhost);
ret = -1;
@@ -456,7 +458,6 @@ sudo_sss_open(struct sudo_nss *nss)
*/
if (strcmp(user_runhost, user_host) == 0) {
if (get_ipa_hostname(&handle->ipa_shost, &handle->ipa_host) == -1) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(handle);
debug_return_int(ENOMEM);
}
@@ -478,7 +479,8 @@ sudo_sss_close(struct sudo_nss *nss)
handle = nss->handle;
sudo_dso_unload(handle->ssslib);
free(handle->ipa_host);
free(handle->ipa_shost);
if (handle->ipa_host != handle->ipa_shost)
free(handle->ipa_shost);
free(handle);
nss->handle = NULL;
}