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:
Sergey Poznyakoff
2015-11-21 21:56:49 +02:00
parent e6fcc73efa
commit e426787454
8 changed files with 88 additions and 15 deletions
+11 -9
View File
@@ -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);
}