]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix wrong fd in restore_parent_fd fallback path
authorWeixie Cui <cuiweixie@gmail.com>
Mon, 9 Mar 2026 11:37:59 +0000 (19:37 +0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 10 Mar 2026 16:46:42 +0000 (09:46 -0700)
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

index a962ed759c38e2bef063aa57b4bb8c8f257b427f..71f183a5fa2e32e06c4d143ce91ce88bc83cc35b 100644 (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