aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_queriesmatch.c
diff options
context:
space:
mode:
authorLudwig Rydberg <ludwig.rydberg@gaisler.com>2023-12-11 13:50:41 +0100
committerFlorian Weimer <fweimer@redhat.com>2023-12-12 09:42:55 +0100
commitfc039ce8502d236f11074eb58468be24b4fa8cc7 (patch)
tree00222e9612157636431bd30d5d2ede9ad5dbd602 /resolv/res_queriesmatch.c
parent4753e9286858a61d5fbe8742d48d8c9166143354 (diff)
downloadglibc-fc039ce8502d236f11074eb58468be24b4fa8cc7.zip
glibc-fc039ce8502d236f11074eb58468be24b4fa8cc7.tar.gz
glibc-fc039ce8502d236f11074eb58468be24b4fa8cc7.tar.bz2
resolv: Fix a few unaligned accesses to fields in HEADER
After refactoring the alloca usage in 40c0add7d4 ("resolve: Remove __res_context_query alloca usage") a few unaligned accesses to HEADER fields surfaced. These unaligned accesses led to problems when running the resolv test suite on sparc32-linux (leon) as many tests failed due to SIGBUS crashes. The issue(s) occured during T_QUERY_A_AND_AAAA queries as the second query now can start on an unaligned address (previously it was explicitly aligned). With this patch the unaligned accesses are now fixed by using the UHEADER instead to ensure the fields are accessed with byte loads/stores. The patch has been verfied by running the resolv test suite on sparc32 and x86_64. Signed-off-by: Ludwig Rydberg <ludwig.rydberg@gaisler.com> Signed-off-by: Andreas Larsson <andreas@gaisler.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'resolv/res_queriesmatch.c')
-rw-r--r--resolv/res_queriesmatch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/resolv/res_queriesmatch.c b/resolv/res_queriesmatch.c
index ba1c1d0..37db01a 100644
--- a/resolv/res_queriesmatch.c
+++ b/resolv/res_queriesmatch.c
@@ -95,14 +95,14 @@ __libc_res_queriesmatch (const unsigned char *buf1, const unsigned char *eom1,
/* Only header section present in replies to dynamic update
packets. */
- if ((((HEADER *) buf1)->opcode == ns_o_update) &&
- (((HEADER *) buf2)->opcode == ns_o_update))
+ if ((((UHEADER *) buf1)->opcode == ns_o_update) &&
+ (((UHEADER *) buf2)->opcode == ns_o_update))
return 1;
/* Note that we initially do not convert QDCOUNT to the host byte
order. We can compare it with the second buffer's QDCOUNT
value without doing this. */
- int qdcount = ((HEADER *) buf1)->qdcount;
+ int qdcount = ((UHEADER *) buf1)->qdcount;
if (qdcount != ((UHEADER *) buf2)->qdcount)
return 0;