mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-04 08:15:15 +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:
@@ -349,6 +349,8 @@ get_ipa_hostname(char **shostp, char **lhostp)
|
|||||||
*lhostp = lhost;
|
*lhostp = lhost;
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__,
|
||||||
|
U_("unable to allocate memory"));
|
||||||
free(shost);
|
free(shost);
|
||||||
free(lhost);
|
free(lhost);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -456,7 +458,6 @@ sudo_sss_open(struct sudo_nss *nss)
|
|||||||
*/
|
*/
|
||||||
if (strcmp(user_runhost, user_host) == 0) {
|
if (strcmp(user_runhost, user_host) == 0) {
|
||||||
if (get_ipa_hostname(&handle->ipa_shost, &handle->ipa_host) == -1) {
|
if (get_ipa_hostname(&handle->ipa_shost, &handle->ipa_host) == -1) {
|
||||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
|
||||||
free(handle);
|
free(handle);
|
||||||
debug_return_int(ENOMEM);
|
debug_return_int(ENOMEM);
|
||||||
}
|
}
|
||||||
@@ -478,6 +479,7 @@ sudo_sss_close(struct sudo_nss *nss)
|
|||||||
handle = nss->handle;
|
handle = nss->handle;
|
||||||
sudo_dso_unload(handle->ssslib);
|
sudo_dso_unload(handle->ssslib);
|
||||||
free(handle->ipa_host);
|
free(handle->ipa_host);
|
||||||
|
if (handle->ipa_host != handle->ipa_shost)
|
||||||
free(handle->ipa_shost);
|
free(handle->ipa_shost);
|
||||||
free(handle);
|
free(handle);
|
||||||
nss->handle = NULL;
|
nss->handle = NULL;
|
||||||
|
Reference in New Issue
Block a user