From: David Woodhouse Date: Wed, 26 Sep 2012 19:42:10 +0000 (+0100) Subject: Fix use-after-free of numeric IPv6 hostname on error path X-Git-Tag: v4.08~14 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=75bf37971d6b73c99faac1977f651e345d5e6434;p=users%2Fdwmw2%2Fopenconnect.git Fix use-after-free of numeric IPv6 hostname on error path Spotted by Coverity. Signed-off-by: David Woodhouse --- diff --git a/ssl.c b/ssl.c index c5115e7b..e9916fbe 100644 --- a/ssl.c +++ b/ssl.c @@ -205,15 +205,17 @@ int connect_https_socket(struct openconnect_info *vpninfo) } err = getaddrinfo(hostname, port, &hints, &result); - if (hints.ai_flags & AI_NUMERICHOST) - free(hostname); if (err) { vpn_progress(vpninfo, PRG_ERR, _("getaddrinfo failed for host '%s': %s\n"), hostname, gai_strerror(err)); + if (hints.ai_flags & AI_NUMERICHOST) + free(hostname); return -EINVAL; } + if (hints.ai_flags & AI_NUMERICHOST) + free(hostname); for (rp = result; rp ; rp = rp->ai_next) { char host[80];