mirror of git://git.musl-libc.org/musl
fix negative response and non-response handling for dns queries
previously, all failures to obtain at least one address were treated as nonexistant names (EAI_NONAME). this failed to account for the possibility of transient failures (no response at all, or a response with rcode of 2, server failure) or permanent failures that do not indicate the nonexistence of the requested name. only an rcode of 3 should be treated as an indication of nonexistence.
This commit is contained in:
parent
ac2a789342
commit
d85d261ee6
|
@ -151,7 +151,10 @@ static int name_from_dns(struct address buf[static MAXADDRS], char canon[static
|
||||||
for (i=0; i<nq; i++)
|
for (i=0; i<nq; i++)
|
||||||
__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx);
|
__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx);
|
||||||
|
|
||||||
return ctx.cnt;
|
if (ctx.cnt) return ctx.cnt;
|
||||||
|
if (alens[0] < 4 || (abuf[0][3] & 15) == 2) return EAI_AGAIN;
|
||||||
|
if ((abuf[0][3] & 15) == 3) return EAI_NONAME;
|
||||||
|
return EAI_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)
|
int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)
|
||||||
|
|
Loading…
Reference in New Issue