]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
tar: fix numbered backup bug
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 28 Oct 2018 23:23:51 +0000 (16:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 28 Oct 2018 23:24:05 +0000 (16:24 -0700)
* src/misc.c (maybe_backup_file): Pass chdir_fd, not AT_FDCWD,
to find_backup_file_name.  This fixes a bug whereby the wrong
backup file name was chosen for numbered backups.

src/misc.c

index 65833b10bdfa952cca85a2c6196a53c26ceb1e36..c7e6f2af8f26e7090f8b4d044148d60768eaf1ff 100644 (file)
@@ -727,7 +727,7 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
       && (S_ISBLK (file_stat.st_mode) || S_ISCHR (file_stat.st_mode)))
     return true;
 
-  after_backup_name = find_backup_file_name (AT_FDCWD, file_name, backup_type);
+  after_backup_name = find_backup_file_name (chdir_fd, file_name, backup_type);
   if (! after_backup_name)
     xalloc_die ();