From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id E39A03858406; Mon, 24 Jan 2022 13:45:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E39A03858406 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4JjB833X5Zz1sYf6; Mon, 24 Jan 2022 14:45:39 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4JjB833DCfz1qqkC; Mon, 24 Jan 2022 14:45:39 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id RkP55XMsSSlq; Mon, 24 Jan 2022 14:45:38 +0100 (CET) X-Auth-Info: 2x4VC4JJht7rCSLbUJUWpl0fKCnBH5ZFIC9MlWIhe656F89+PZco1M71hX3YvY++ Received: from igel.home (ppp-46-244-179-110.dynamic.mnet-online.de [46.244.179.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 24 Jan 2022 14:45:38 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 3FDBC2C3737; Mon, 24 Jan 2022 14:45:38 +0100 (CET) From: Andreas Schwab To: Siddhesh Poyarekar via Libc-alpha Cc: Siddhesh Poyarekar , fweimer@redhat.com Subject: Re: [PATCH v3 2/3] realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770] References: <20220119082147.3352868-1-siddhesh@sourceware.org> <20220120093252.1911498-1-siddhesh@sourceware.org> <20220120093252.1911498-3-siddhesh@sourceware.org> X-Yow: Are we THERE yet? My MIND is a SUBMARINE!! Date: Mon, 24 Jan 2022 14:45:38 +0100 In-Reply-To: <20220120093252.1911498-3-siddhesh@sourceware.org> (Siddhesh Poyarekar via Libc-alpha's message of "Thu, 20 Jan 2022 15:02:51 +0530") Message-ID: <87r18x8cxp.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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: , X-List-Received-Date: Mon, 24 Jan 2022 13:45:42 -0000 On Jan 20 2022, Siddhesh Poyarekar via Libc-alpha wrote: > diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c > index f36bdf4c76..732dc7ea46 100644 > --- a/stdlib/canonicalize.c > +++ b/stdlib/canonicalize.c > @@ -400,8 +400,16 @@ realpath_stk (const char *name, char *resolved, > > error: > *dest++ = '\0'; > - if (resolved != NULL && dest - rname <= get_path_max ()) > - rname = strcpy (resolved, rname); > + if (resolved != NULL) > + { > + if (dest - rname <= get_path_max ()) > + rname = strcpy (resolved, rname); > + else > + { > + failed = true; > + __set_errno (ENAMETOOLONG); > + } > + } Shouldn't that preserve any preexisting error? I think the result should only be copied if !failed. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."