From patchwork Wed Sep 8 22:52:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 44916 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A686C384F02A for ; Wed, 8 Sep 2021 22:53:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by sourceware.org (Postfix) with ESMTPS id 6074D3857817 for ; Wed, 8 Sep 2021 22:52:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6074D3857817 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=aurel32.net Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aurel32.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From:Content-Type:From:Reply-To:Subject:Content-ID: Content-Description:In-Reply-To:References:X-Debbugs-Cc; bh=S5oFhKuuW5pkqHRXQfcwF9L3qytlJH6x3rGaPxAh6eI=; b=BSLtm8vihco8FoxrDwIbCSTVYv xg0bQY80JjmBqaIJRSI3/NZ0UgFPOPs11pg9lxuWKa/x+w3hwLBzQ1BWA0b4JTXZw5lHRq9ijDXR+ u/e0Oy3KMQcvlqlH6YKyga4axKkuZDegDvLLsv/1DcdtCggai/piuXsP8fThCq8VTKX+Thd1O+Kms J3dQDOgpo9pXc11CFJumklkj3K+yyd2yX+5JRnGSqMxtu8zu0r0kenYOZuOgvam16PLZ+vXLp/I3f NWVWq8a6hITTr8rjCo+0jfkmLQCplCEjI724Kza+6ENWXmr3Uvcl6NC7YaTcb5GEb39jAzj34XQ/z DsdBEFUg==; Received: from [2a01:e34:ec5d:a741:8a4c:7c4e:dc4c:1787] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mO6R6-0006HB-Fx; Thu, 09 Sep 2021 00:52:56 +0200 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.94.2) (envelope-from ) id 1mO6R5-00GQdz-T3; Thu, 09 Sep 2021 00:52:55 +0200 From: Aurelien Jarno To: libc-alpha@sourceware.org Subject: [PATCH] posix: Fix attribute access mode on getcwd with GNU extension [BZ #27476] Date: Thu, 9 Sep 2021 00:52:50 +0200 Message-Id: <20210908225250.3912555-1-aurelien@aurel32.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: Aurelien Jarno Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" There is a GNU extension that allows to call getcwd(NULL, >0). It is described in the documentation, but also directly in the unistd.h header, just above the declaration. Therefore, do not define the attribute access mode when __USE_GNU is in used. --- posix/unistd.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Note: I am aware of BZ #26545, however while it is being discussed, the bug is still there, so I don't think we should block on a decision to fix it. diff --git a/posix/unistd.h b/posix/unistd.h index 3dca65732f..506d34d2ec 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -529,7 +529,10 @@ extern int fchdir (int __fd) __THROW __wur; bytes long, unless SIZE == 0, in which case it is as big as necessary. */ extern char *getcwd (char *__buf, size_t __size) __THROW __wur - __attr_access ((__write_only__, 1, 2)); +#ifndef __USE_GNU + __attr_access ((__write_only__, 1, 2)) +#endif + ; #ifdef __USE_GNU /* Return a malloc'd string containing the current directory name.