From f466b43975f77ee298ff892f57c18b23fb8d28fc Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 16 Jan 2022 19:50:40 -0500 Subject: [PATCH] lib/krb5: fallback_get_hosts free addrinfo if gTLD collision or error If getaddrinfo() succeeds and returns the gTLD name collision address the result is ignored but the allocated addrinfo was not freed. If allocation of the krb5_krbhst_info structure fails the addrinfo would also be leaked. Change-Id: I94111e081cba9548f57ad7b7e7cbea3faab7502c --- lib/krb5/krbhst.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index 53b178050..9f0313f9a 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -562,6 +562,7 @@ fallback_get_hosts(krb5_context context, struct krb5_krbhst_data *kd, "Realm %s needs immediate attention " "see https://icann.org/namecollision", kd->realm); + freeaddrinfo(ai); return KRB5_KDC_UNREACH; } } @@ -570,6 +571,7 @@ fallback_get_hosts(krb5_context context, struct krb5_krbhst_data *kd, hi = calloc(1, sizeof(*hi) + hostlen); if(hi == NULL) { free(host); + freeaddrinfo(ai); return krb5_enomem(context); }