nss_dns: Do not use deprecated packet parsing functions

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Florian Weimer 2021-07-15 08:28:50 +02:00
parent 389c1114d1
commit 2ff32dd492
2 changed files with 20 additions and 21 deletions

View File

@ -150,15 +150,18 @@ _nss_dns_getcanonname_r (const char *name, char *buffer, size_t buflen,
if (type != ns_t_cname) if (type != ns_t_cname)
goto unavail; goto unavail;
if (__ns_get16 (ptr) != ns_c_in) uint16_t rrclass;
NS_GET16 (rrclass, ptr);
if (rrclass != ns_c_in)
goto unavail; goto unavail;
/* Also skip over class and TTL. */ /* Skip over TTL. */
ptr += sizeof (uint16_t) + sizeof (uint32_t); ptr += sizeof (uint32_t);
/* Skip over RDATA length and RDATA itself. */ /* Skip over RDATA length and RDATA itself. */
uint16_t rdatalen = __ns_get16 (ptr); uint16_t rdatalen;
ptr += sizeof (uint16_t); NS_GET16 (rdatalen, ptr);
/* Not enough room for RDATA. */ /* Not enough room for RDATA. */
if (endptr - ptr < rdatalen) if (endptr - ptr < rdatalen)
goto unavail; goto unavail;

View File

@ -782,14 +782,11 @@ getanswer_r (struct resolv_context *ctx,
continue; continue;
} }
type = __ns_get16 (cp); NS_GET16 (type, cp);
cp += INT16SZ; /* type */ NS_GET16 (class, cp);
class = __ns_get16 (cp); int32_t ttl;
cp += INT16SZ; /* class */ NS_GET32 (ttl, cp);
int32_t ttl = __ns_get32 (cp); NS_GET16 (n, cp); /* RDATA length. */
cp += INT32SZ; /* TTL */
n = __ns_get16 (cp);
cp += INT16SZ; /* len */
if (end_of_message - cp < n) if (end_of_message - cp < n)
{ {
@ -1116,14 +1113,13 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname,
continue; continue;
} }
int type = __ns_get16 (cp); uint16_t type;
cp += INT16SZ; /* type */ NS_GET16 (type, cp);
int class = __ns_get16 (cp); uint16_t class;
cp += INT16SZ; /* class */ NS_GET16 (class, cp);
int32_t ttl = __ns_get32 (cp); int32_t ttl;
cp += INT32SZ; /* TTL */ NS_GET32 (ttl, cp);
n = __ns_get16 (cp); NS_GET16 (n, cp); /* RDATA length. */
cp += INT16SZ; /* len */
if (end_of_message - cp < n) if (end_of_message - cp < n)
{ {