Skip to content

Commit

Permalink
Fix use-after-free of numeric IPv6 hostname on error path
Browse files Browse the repository at this point in the history
Spotted by Coverity.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Sep 26, 2012
1 parent 306a0fc commit 75bf379
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ssl.c
Expand Up @@ -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];
Expand Down

0 comments on commit 75bf379

Please sign in to comment.