diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-07-17 19:58:39 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-07-17 20:03:33 -0400 |
commit | d24941bb85f8ccc41a9894871e7cca7a02de066c (patch) | |
tree | 5670e58bc52132d953dce2349e09e36f7ef7c367 | |
parent | 196c36bb13de94c977a3e360dc5fa529efe2c5ca (diff) | |
download | bfs-d24941bb85f8ccc41a9894871e7cca7a02de066c.tar.xz |
bftw: Check that file->fd == bfs_dirfd(file->dir) earlier
This has the potential to fail on at least one known platform: macports
with the legacysupport implementation of fdopendir().
Link: https://github.com/macports/macports-ports/pull/19047#issuecomment-1636059809
-rw-r--r-- | src/bftw.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -219,7 +219,6 @@ static void bftw_file_close(struct bftw_cache *cache, struct bftw_file *file) { bfs_assert(file->pincount == 0); if (file->dir) { - bfs_assert(file->fd == bfs_dirfd(file->dir)); bfs_closedir(file->dir); bftw_freedir(cache, file->dir); file->dir = NULL; @@ -354,7 +353,9 @@ static void bftw_file_set_dir(struct bftw_cache *cache, struct bftw_file *file, bfs_assert(!file->dir); file->dir = dir; - if (file->fd < 0) { + if (file->fd >= 0) { + bfs_assert(file->fd == bfs_dirfd(dir)); + } else { file->fd = bfs_dirfd(dir); bftw_cache_add(cache, file); } |