From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 26CC01F45D for ; Sun, 22 Mar 2020 01:42:07 +0000 (UTC) Received: from localhost ([::1]:42514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFpcr-0005rm-U9 for normalperson@yhbt.net; Sat, 21 Mar 2020 21:42:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47027) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFpcn-0005rU-FU for bug-gnulib@gnu.org; Sat, 21 Mar 2020 21:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFpcm-0000CH-A1 for bug-gnulib@gnu.org; Sat, 21 Mar 2020 21:42:01 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::8]:14012) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jFpcl-0000B5-LU for bug-gnulib@gnu.org; Sat, 21 Mar 2020 21:42:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1584841315; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=ClhwxMCsEQQXzDvz2a2dHSqhsBQuASdZ6a94AyxNOjs=; b=TXgAqWWbmGS/mxoGA+9LeFkRegIfE5OsS3gV3CMTjsDKh8pWF7d3p8K6EBB6OYErJl Ze3dY2bsZDQ3Rtpy2BaDy4SYXiNzD1+1IbKa2FiwOFIAaicyyDW1hDgPJgZtj+rSrnnL PMEio4izm4bVBRGi7/LXZ9K/u4hW1Kap/mz18RHLPIEJb4cSfJ8cv48g1M1AXsoedQZq ZQZsZ98sLHjunehTTGXijznJN9bvRt/8Vf2rEuFk0sEUXGHZ/na8vEA/Swdc0jRWXndO w7lcURXhvp9qZmAgBLnECVkQa6R7+sP6UtbF0hobxUamrTVh3d9iHlwz7DIi2vfr8QJI tjMg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.2.1 DYNA|AUTH) with ESMTPSA id R09594w2M1fhCYd (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Sun, 22 Mar 2020 02:41:43 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: rpl_unlink sets errno to EPERM on malloc failure Date: Sun, 22 Mar 2020 02:41:42 +0100 Message-ID: <6420016.ctEZgyEJku@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-174-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <156fab0e-2e6f-bf6a-dcf4-e0b283ad8ef1@cs.ucla.edu> References: <6e8ef102-a270-91f4-12e4-6a42e3ebbebf@gmx.de> <156fab0e-2e6f-bf6a-dcf4-e0b283ad8ef1@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::8 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tim =?ISO-8859-1?Q?R=FChsen?= , Paul Eggert Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Paul Eggert wrote: --- a/lib/unlink.c +++ b/lib/unlink.c @@ -65,10 +65,7 @@ rpl_unlink (char const *name) /* Trailing NUL will overwrite the trailing slash. */ char *short_name = malloc (len); if (!short_name) - { - errno = EPERM; - return -1; - } + return -1; memcpy (short_name, name, len); while (len && ISSLASH (short_name[len - 1])) short_name[--len] = '\0'; But while on POSIX systems, malloc() is guaranteed to set errno when it fails, for native Windows systems we need the 'malloc-posix' module, in order to guarantee this. 2020-03-21 Bruno Haible unlink: Ensure errno also on native Windows. * modules/unlink (Depends-on): Add malloc-posix. diff --git a/modules/unlink b/modules/unlink index 63720aa..5fc84d9 100644 --- a/modules/unlink +++ b/modules/unlink @@ -9,6 +9,7 @@ Depends-on: unistd dosname [test $REPLACE_UNLINK = 1] lstat [test $REPLACE_UNLINK = 1] +malloc-posix [test $REPLACE_UNLINK = 1] configure.ac: gl_FUNC_UNLINK