mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
selftest/net/ovpn: fix crash in case of getaddrinfo() failure
getaddrinfo() may fail with error code different from EAI_FAIL
or EAI_NONAME, however in this case we still try to free the
results object, thus leading to a crash.
Fix this by bailing out on any possible error.
Fixes: 959bc330a4 ("testing/selftests: add test tool and scripts for ovpn module")
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
This commit is contained in:
parent
4ca6438da4
commit
8624daf9f2
|
|
@ -1753,8 +1753,11 @@ static int ovpn_parse_remote(struct ovpn_ctx *ovpn, const char *host,
|
|||
|
||||
if (host) {
|
||||
ret = getaddrinfo(host, service, &hints, &result);
|
||||
if (ret == EAI_NONAME || ret == EAI_FAIL)
|
||||
if (ret) {
|
||||
fprintf(stderr, "getaddrinfo on remote error: %s\n",
|
||||
gai_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(result->ai_family == AF_INET &&
|
||||
result->ai_addrlen == sizeof(struct sockaddr_in)) &&
|
||||
|
|
@ -1769,8 +1772,11 @@ static int ovpn_parse_remote(struct ovpn_ctx *ovpn, const char *host,
|
|||
|
||||
if (vpnip) {
|
||||
ret = getaddrinfo(vpnip, NULL, &hints, &result);
|
||||
if (ret == EAI_NONAME || ret == EAI_FAIL)
|
||||
if (ret) {
|
||||
fprintf(stderr, "getaddrinfo on vpnip error: %s\n",
|
||||
gai_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(result->ai_family == AF_INET &&
|
||||
result->ai_addrlen == sizeof(struct sockaddr_in)) &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user