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
This commit is contained in:
Weixie Cui
2026-03-09 19:37:59 +08:00
committed by Paul Eggert
parent c8f2800b9b
commit af552a0769

View File

@@ -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