]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
--one-top-level now keeps "../" and ".../"
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 7 Apr 2026 18:11:21 +0000 (11:11 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 8 Apr 2026 16:07:12 +0000 (09:07 -0700)
* src/list.c (enforce_one_top_level): Do not strip prefixes like
"../" (which should not be allowed unless -P) and ".../" (which
are ordinary file names).  The "../" not being allowed should be
addressed in a different way.

src/list.c

index 8e9caf5ce58cbf1967e2944c5ffa7ee8a9e9903f..14050cfb2ea683e5e7f10467fc49c3353b2b20ea 100644 (file)
@@ -120,8 +120,16 @@ enforce_one_top_level (char **pfile_name)
   char *file_name = *pfile_name;
   char *p;
 
-  for (p = file_name; *p && (ISSLASH (*p) || *p == '.'); p++)
-    ;
+  for (p = file_name; ; p++)
+    {
+      bool dot = p[0] == '.';
+      if (!ISSLASH (p[dot]))
+       {
+         p += dot & !p[dot];
+         break;
+       }
+      p += dot;
+    }
 
   if (*p)
     {