resolv: Fix some unaligned accesses in resolver [BZ #30750]

Signed-off-by: John David Anglin <dave.anglin@bell.net>
This commit is contained in:
John David Anglin 2023-09-13 11:04:41 +00:00
parent f510d75ff7
commit 5aa4bb67b9
2 changed files with 4 additions and 2 deletions

View File

@ -84,6 +84,7 @@
#include <arpa/nameser.h> #include <arpa/nameser.h>
#include <resolv.h> #include <resolv.h>
#include <resolv/resolv-internal.h>
/* Author: paul vixie, 29may94. */ /* Author: paul vixie, 29may94. */
int int
@ -91,7 +92,7 @@ __libc_res_nameinquery (const char *name, int type, int class,
const unsigned char *buf, const unsigned char *eom) const unsigned char *buf, const unsigned char *eom)
{ {
const unsigned char *cp = buf + HFIXEDSZ; const unsigned char *cp = buf + HFIXEDSZ;
int qdcount = ntohs (((HEADER *) buf)->qdcount); int qdcount = ntohs (((UHEADER *) buf)->qdcount);
while (qdcount-- > 0) while (qdcount-- > 0)
{ {

View File

@ -83,6 +83,7 @@
*/ */
#include <resolv.h> #include <resolv.h>
#include <resolv/resolv-internal.h>
/* Author: paul vixie, 29may94. */ /* Author: paul vixie, 29may94. */
int int
@ -102,7 +103,7 @@ __libc_res_queriesmatch (const unsigned char *buf1, const unsigned char *eom1,
order. We can compare it with the second buffer's QDCOUNT order. We can compare it with the second buffer's QDCOUNT
value without doing this. */ value without doing this. */
int qdcount = ((HEADER *) buf1)->qdcount; int qdcount = ((HEADER *) buf1)->qdcount;
if (qdcount != ((HEADER *) buf2)->qdcount) if (qdcount != ((UHEADER *) buf2)->qdcount)
return 0; return 0;
qdcount = htons (qdcount); qdcount = htons (qdcount);