From: Pádraig Brady
Date: Thu, 16 Sep 2021 22:31:07 +0000 (+0100) Subject: rmdir: fix uninitialized memory causing incorrect error X-Git-Tag: v9.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14ed8b8810508d284df21a06b14093537a24e4cf;p=thirdparty%2Fcoreutils.git rmdir: fix uninitialized memory causing incorrect error * src/rmdir.c (main): Only inspect the returned stat structure, when stat(2) returns success. --- diff --git a/src/rmdir.c b/src/rmdir.c index 149d4659a9..c6e2aba0f2 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))) { /* Ensure the last component was a symlink. */ char* dir_arg = xstrdup (dir);