diff options
| author | Pádraig Brady <P@draigBrady.com> | 2021-09-16 23:31:07 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2021-09-16 23:45:16 +0100 |
| commit | 14ed8b8810508d284df21a06b14093537a24e4cf (patch) | |
| tree | 367ac5d10950d9ef81d6b64aeedc6358d6d7dad1 | |
| parent | build: avoid new chmod.c warnings from upcoming GCC12 (diff) | |
| download | coreutils-14ed8b8810508d284df21a06b14093537a24e4cf.tar.gz coreutils-14ed8b8810508d284df21a06b14093537a24e4cf.zip | |
rmdir: fix uninitialized memory causing incorrect error
* src/rmdir.c (main): Only inspect the returned stat structure,
when stat(2) returns success.
| -rw-r--r-- | src/rmdir.c | 3 |
1 files changed, 2 insertions, 1 deletions
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))) { /* Ensure the last component was a symlink. */ char* dir_arg = xstrdup (dir); |
