From patchwork Mon Aug 28 19:59:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 1826910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZLxx41qRz1yZs for ; Tue, 29 Aug 2023 06:00:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36A9B3858C54 for ; Mon, 28 Aug 2023 20:00:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dellerweb.de (unknown [IPv6:2a02:c207:3003:236::1]) by sourceware.org (Postfix) with ESMTPS id 4B2053858402 for ; Mon, 28 Aug 2023 19:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B2053858402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=parisc-linux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=parisc-linux.org Received: from mx3210.localdomain (unknown [142.198.135.111]) by dellerweb.de (Postfix) with ESMTPSA id 518E4160019B; Mon, 28 Aug 2023 21:59:46 +0200 (CEST) Received: by mx3210.localdomain (Postfix, from userid 1000) id 53EEB22011C; Mon, 28 Aug 2023 19:59:39 +0000 (UTC) Date: Mon, 28 Aug 2023 19:59:39 +0000 From: John David Anglin To: libc-alpha@sourceware.org Cc: Helge Deller Subject: resolv: Fix some unaligned accesses in resolver [BZ #30750] Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Okay to install? resolv: Fix some unaligned accesses in resolver [BZ #30750] Signed-off-by: John David Anglin diff --git a/resolv/res_nameinquery.c b/resolv/res_nameinquery.c index 24172700e1..ca56bc9283 100644 --- a/resolv/res_nameinquery.c +++ b/resolv/res_nameinquery.c @@ -84,6 +84,7 @@ #include #include +#include /* Author: paul vixie, 29may94. */ 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 *cp = buf + HFIXEDSZ; - int qdcount = ntohs (((HEADER *) buf)->qdcount); + int qdcount = ntohs (((UHEADER *) buf)->qdcount); while (qdcount-- > 0) { diff --git a/resolv/res_queriesmatch.c b/resolv/res_queriesmatch.c index 13a6936c47..ba1c1d0c0c 100644 --- a/resolv/res_queriesmatch.c +++ b/resolv/res_queriesmatch.c @@ -83,6 +83,7 @@ */ #include +#include /* Author: paul vixie, 29may94. */ 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 value without doing this. */ int qdcount = ((HEADER *) buf1)->qdcount; - if (qdcount != ((HEADER *) buf2)->qdcount) + if (qdcount != ((UHEADER *) buf2)->qdcount) return 0; qdcount = htons (qdcount);