rm-rf: Make sure we rewinddir() before readdir()

We don't know what state the passed in file descriptor is in. Let's
make sure we rewind it before iterating over it.

Fixes #29606
This commit is contained in:
Daan De Meyer
2023-10-20 11:55:53 +01:00
committed by Luca Boccassi
parent cf37171890
commit 6bbb893b90
+4
View File
@@ -365,6 +365,10 @@ static int rm_rf_children_impl(
strna(path));
}
}
/* Make sure we reset the iterator since we don't know the state the passed in file
* descriptor is in. */
rewinddir(d);
}
FOREACH_DIRENT_ALL(de, d, return -errno) {