From patchwork Mon Sep 19 13:39:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 1679427 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=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=u/sVv5z+; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MWQlw1PKWz1ypM for ; Mon, 19 Sep 2022 23:40:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35DB33858D1E for ; Mon, 19 Sep 2022 13:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35DB33858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663594810; bh=lyQbq+Dgwapa9+Ztc8CJdMeaiM4AvukwsS4i2ComGH8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=u/sVv5z+mq7medNva3OoiSP/a7cPSwpENcuTNgQ+1x5ta/HLlVSkjkU6gfzAzabcV WOD/ZyceF+dZHWWS5ocNxj1ONkg2Dag+IrmGS1y701+dPxl0Sqq0FzF5mqod00g68T sKfT/5ITOvNTcVqD6TpGnrgcVUpu3NW6FXMHtlbE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 21B733858418 for ; Mon, 19 Sep 2022 13:39:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21B733858418 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4F4E722169 for ; Mon, 19 Sep 2022 13:39:18 +0000 (UTC) Received: from hawking.suse.de (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 484552C141 for ; Mon, 19 Sep 2022 13:39:18 +0000 (UTC) Received: by hawking.suse.de (Postfix, from userid 17005) id F35B844021C; Mon, 19 Sep 2022 15:39:17 +0200 (CEST) To: libc-alpha@sourceware.org Subject: [PATCH] socket: Use offsetof in SUN_LEN (bug 29578) X-Yow: Two with FLUFFO, hold th' BEETS..side of SOYETTES! Date: Mon, 19 Sep 2022 15:39:17 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, 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.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andreas Schwab via Libc-alpha From: Andreas Schwab Reply-To: Andreas Schwab Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Use offsetof instead of its traditional expansion in the definition of the SUN_LEN macro, to avoid a warning from the undefined behaviour sanitizer. Reviewed-by: Adhemerval Zanella --- socket/sys/un.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/socket/sys/un.h b/socket/sys/un.h index 454eafebc9..2b11300e28 100644 --- a/socket/sys/un.h +++ b/socket/sys/un.h @@ -34,10 +34,11 @@ struct sockaddr_un #ifdef __USE_MISC +# include # include /* For prototype of `strlen'. */ /* Evaluate to actual length of the `sockaddr_un' structure. */ -# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ +# define SUN_LEN(ptr) (offsetof (struct sockaddr_un, sun_path) \ + strlen ((ptr)->sun_path)) #endif