dirmngr: Improve error handling.

* dirmngr/dns-stuff.c (getsrv): Avoid looking at 'header' before
checking for errors, but silently ignore errors when looking up SRV
records.
--
This is a follow-up to 946faaff.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2015-12-01 13:24:38 +01:00
parent 9f4f77bc4b
commit 9c34711539
1 changed files with 2 additions and 3 deletions

View File

@ -1086,10 +1086,9 @@ getsrv (const char *name,struct srventry **list)
return -1;
r = res_query (name, C_IN, T_SRV, answer, sizeof answer);
if (header->rcode != NOERROR || !(count=ntohs (header->ancount)))
if (r < sizeof (HEADER) || r > sizeof answer
|| header->rcode != NOERROR || !(count=ntohs (header->ancount)))
return 0; /* Error or no record found. */
if (r < sizeof (HEADER) || r > sizeof answer)
return -1;
emsg = &answer[r];
pt = &answer[sizeof(HEADER)];