mirror of
https://github.com/systemd/systemd.git
synced 2026-08-03 22:50:29 +00:00
stat-util: ignore hidden_or_backup_file when checking if dir is empty
Commit https://github.com/systemd/systemd/commit/a068aceafbf changed dir_is_emtpy_at to use FOREACH_DIRENT_IN_BUFFER instead of FOREACH_DIRENT, but used dot_or_dotdot which just checks if the name is literally '.' or '..' which is not enough, previous behaviour was to ignore all hidden files, so restore that and add a test case. Fixes https://github.com/systemd/systemd/issues/23220
This commit is contained in:
committed by
Yu Watanabe
parent
dfd672f84b
commit
f470cb6d13
@@ -106,7 +106,7 @@ int dir_is_empty_at(int dir_fd, const char *path) {
|
||||
msan_unpoison(&buffer, n);
|
||||
|
||||
FOREACH_DIRENT_IN_BUFFER(de, &buffer.de, n)
|
||||
if (!dot_or_dot_dot(de->d_name))
|
||||
if (!hidden_or_backup_file(de->d_name))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user