coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] rmdir: fix uninitialized memory causing incorrect error


From: Jim Meyering
Subject: Re: [PATCH] rmdir: fix uninitialized memory causing incorrect error
Date: Thu, 16 Sep 2021 16:05:36 -0700

On Thu, Sep 16, 2021 at 3:35 PM Pádraig Brady <P@draigbrady.com> wrote:
> * src/rmdir.c (main): Only inspect the returned stat structure,
> when stat(2) returns success.
> ---
>  src/rmdir.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/rmdir.c b/src/rmdir.c
> index 149d4659a..c6e2aba0f 100644
> --- a/src/rmdir.c
> +++ b/src/rmdir.c
> @@ -262,7 +262,8 @@ main (int argc, char **argv)
>                    struct stat st;
>                    int ret = stat (dir, &st);
>                    /* Some other issue following, or is actually a directory. 
> */
> -                  if ((ret != 0 && errno != ENOTDIR) || S_ISDIR (st.st_mode))
> +                  if ((ret != 0 && errno != ENOTDIR)
> +                      || (ret == 0 && S_ISDIR (st.st_mode)))

Good one!
Found via valgrind?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]