mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-09-05 15:56:55 +00:00
Fix bug in the inplementation of --one-top-level.
When extracting an archive that contains './' with the --one-top-level option, the mode and ownership of '.' would be incorrectly applied to the current working directory, instead of the requested top-level directory. * src/list.c (enforce_one_top_level): Map '.' to the top-level directory. * tests/Makefile.am: Add onetop05.at * tests/testsuite.at: Include onetop05.at. * tests/onetop05.at: New file. * tests/onetop01.at: Fix keywords. * tests/onetop02.at: Likewise. * tests/onetop03.at: Likewise. * tests/onetop04.at: Likewise.
This commit is contained in:
+11
-9
@@ -124,18 +124,20 @@ enforce_one_top_level (char **pfile_name)
|
||||
for (p = file_name; *p && (ISSLASH (*p) || *p == '.'); p++)
|
||||
;
|
||||
|
||||
if (!*p)
|
||||
return;
|
||||
|
||||
if (strncmp (p, one_top_level_dir, strlen (one_top_level_dir)) == 0)
|
||||
if (*p)
|
||||
{
|
||||
int pos = strlen (one_top_level_dir);
|
||||
if (ISSLASH (p[pos]) || p[pos] == 0)
|
||||
return;
|
||||
if (strncmp (p, one_top_level_dir, pos) == 0)
|
||||
{
|
||||
if (ISSLASH (p[pos]) || p[pos] == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
*pfile_name = new_name (one_top_level_dir, file_name);
|
||||
normalize_filename_x (*pfile_name);
|
||||
}
|
||||
|
||||
*pfile_name = new_name (one_top_level_dir, file_name);
|
||||
normalize_filename_x (*pfile_name);
|
||||
else
|
||||
*pfile_name = xstrdup (one_top_level_dir);
|
||||
free (file_name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user