Don't return on file lookup failure, set status

When resolving a host via /etc/hosts, don't return with a predefined
error as there may be other tries.

Fix By: Brad House (@bradh352)
pull/459/head
bradh352 3 years ago
parent d6b2bafe7e
commit 320b99bb9c
  1. 13
      src/lib/ares_getaddrinfo.c

@ -466,16 +466,21 @@ static int file_lookup(struct host_query *hquery)
{ {
case ENOENT: case ENOENT:
case ESRCH: case ESRCH:
return ARES_ENOTFOUND; status = ARES_ENOTFOUND;
break;
default: default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error, DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", error,
strerror(error))); strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n", path_hosts)); DEBUGF(fprintf(stderr, "Error opening file: %s\n", path_hosts));
return ARES_EFILE; status = ARES_EFILE;
break;
} }
} }
status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai); else
fclose(fp); {
status = ares__readaddrinfo(fp, hquery->name, hquery->port, &hquery->hints, hquery->ai);
fclose(fp);
}
/* RFC6761 section 6.3 #3 states that "Name resolution APIs and libraries /* RFC6761 section 6.3 #3 states that "Name resolution APIs and libraries
* SHOULD recognize localhost names as special and SHOULD always return the * SHOULD recognize localhost names as special and SHOULD always return the

Loading…
Cancel
Save