[PATCH] D78945: TarWriter: Only use 137 of the 155 prefix bytes.

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 10:44:06 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG90d6ed144c13: TarWriter: Only use 137 of the 155 prefix bytes. (authored by thakis).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78945/new/

https://reviews.llvm.org/D78945

Files:
  llvm/lib/Support/TarWriter.cpp


Index: llvm/lib/Support/TarWriter.cpp
===================================================================
--- llvm/lib/Support/TarWriter.cpp
+++ llvm/lib/Support/TarWriter.cpp
@@ -131,7 +131,17 @@
     return true;
   }
 
-  size_t Sep = Path.rfind('/', sizeof(UstarHeader::Prefix) + 1);
+  // tar 1.13 and earlier unconditionally look at the tar header interpreted
+  // as an 'oldgnu_header', which has an 'isextended' byte at offset 482 in the
+  // header, corresponding to offset 137 in the prefix. That's the version of
+  // tar in gnuwin, so only use 137 of the 155 bytes in the prefix. This means
+  // we'll need a pax header after 237 bytes of path instead of after 255,
+  // but in return paths up to 237 bytes work with gnuwin, instead of just
+  // 137 bytes of directory + 100 bytes of basename previously.
+  // (tar-1.13 also doesn't support pax headers, but in practice all paths in
+  // llvm's test suite are short enough for that to not matter.)
+  const int MaxPrefix = 137;
+  size_t Sep = Path.rfind('/', MaxPrefix + 1);
   if (Sep == StringRef::npos)
     return false;
   if (Path.size() - Sep - 1 >= sizeof(UstarHeader::Name))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78945.260375.patch
Type: text/x-patch
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/0de3b176/attachment.bin>


More information about the llvm-commits mailing list