From af552a0769a29d1006df6b842ac8f6225b6d415f Mon Sep 17 00:00:00 2001 From: Weixie Cui Date: Mon, 9 Mar 2026 19:37:59 +0800 Subject: [PATCH] Fix wrong fd in restore_parent_fd fallback path Use fstat(origfd) instead of fstat(parentfd) when verifying the alternatively-opened directory; parentfd is invalid in this branch. Copyright-paperwork-exempt: yes --- src/create.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/create.c b/src/create.c index a962ed75..71f183a5 100644 --- a/src/create.c +++ b/src/create.c @@ -1588,7 +1588,7 @@ restore_parent_fd (struct tar_stat_info const *st) : openat (f.fd, f.base, open_searchdir_how.flags)); if (0 <= origfd) { - if (fstat (parentfd, &parentstat) < 0 + if (fstat (origfd, &parentstat) < 0 || !psame_inode (&parent->stat, &parentstat)) close (origfd); else