public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org>
Cc: Siddhesh Poyarekar <siddhesh@sourceware.org>,
	 fweimer@redhat.com, Qualys Security Advisory <qsa@qualys.com>
Subject: Re: [PATCH 3/3] getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)
Date: Tue, 18 Jan 2022 12:52:21 +0100	[thread overview]
Message-ID: <87a6ft8dmy.fsf@igel.home> (raw)
In-Reply-To: <20220118090728.1825487-4-siddhesh@sourceware.org> (Siddhesh Poyarekar via Libc-alpha's message of "Tue, 18 Jan 2022 14:37:28 +0530")

On Jan 18 2022, Siddhesh Poyarekar via Libc-alpha wrote:

> diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c
> index a6b5a7e8b0..5ff678d674 100644
> --- a/sysdeps/unix/sysv/linux/getcwd.c
> +++ b/sysdeps/unix/sysv/linux/getcwd.c
> @@ -50,6 +50,13 @@ __getcwd (char *buf, size_t size)
>    char *path;
>    char *result;
>  
> +  /* A size of 1 byte is never useful.  */
> +  if (size == 1)
> +    {
> +      __set_errno (ERANGE);
> +      return NULL;
> +    }
> +

This is not needed, since the getcwd syscall does the check already and
returns the correct error.

-- 
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."

  reply	other threads:[~2022-01-18 11:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18  9:07 [PATCH 0/3] Fixes for CVE-2021-3998 and CVE-2021-3999 Siddhesh Poyarekar
2022-01-18  9:07 ` [PATCH 1/3] support: Add helpers to create paths longer than PATH_MAX Siddhesh Poyarekar
2022-01-18 19:42   ` Adhemerval Zanella
2022-01-19  1:33     ` Siddhesh Poyarekar
2022-01-18  9:07 ` [PATCH 2/3] realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770] Siddhesh Poyarekar
2022-01-18 19:43   ` Adhemerval Zanella
2022-01-18  9:07 ` [PATCH 3/3] getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999) Siddhesh Poyarekar
2022-01-18 11:52   ` Andreas Schwab [this message]
2022-01-18 13:10     ` Siddhesh Poyarekar
2022-01-18 13:13       ` Andreas Schwab
2022-01-18 13:16         ` Siddhesh Poyarekar
2022-01-18 13:30           ` Andreas Schwab
2022-01-18 13:33             ` Siddhesh Poyarekar
2022-01-18 13:41               ` Andreas Schwab
2022-01-18 13:45                 ` Siddhesh Poyarekar
2022-01-18 13:56                   ` Siddhesh Poyarekar
2022-01-18 13:57                   ` Andreas Schwab
2022-01-18 14:40                     ` Siddhesh Poyarekar
2022-01-18 13:59                   ` Adhemerval Zanella
2022-01-18 14:44                     ` Siddhesh Poyarekar
2022-01-18 16:30                       ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6ft8dmy.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=qsa@qualys.com \
    --cc=siddhesh@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).