diff options
author | Rui Ueyama <ruiu@google.com> | 2017-01-09 22:55:00 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2017-01-09 22:55:00 +0000 |
commit | 7f31bf6e15765b4a1fe5667ea780c521d949e714 (patch) | |
tree | 2a4d44ccc520968578ec279d531996907a94db80 /lib/Support/TarWriter.cpp | |
parent | 2a668d89cacb816a4dbd4079a473af1375092f10 (diff) |
TarWriter: Fix a bug in Ustar header.
If we split a filename into `Name` and `Prefix`, `Prefix` is at most
145 bytes. We had a bug that didn't split a path correctly. This bug
was pointed out by Rafael in the post commit review.
This patch adds a unit test for TarWriter to verify the fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291494 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/TarWriter.cpp')
-rw-r--r-- | lib/Support/TarWriter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Support/TarWriter.cpp b/lib/Support/TarWriter.cpp index 58abffcca55..f06abf46cce 100644 --- a/lib/Support/TarWriter.cpp +++ b/lib/Support/TarWriter.cpp @@ -122,7 +122,7 @@ static void writePaxHeader(raw_fd_ostream &OS, StringRef Path) { static std::pair<StringRef, StringRef> splitPath(StringRef Path) { if (Path.size() <= sizeof(UstarHeader::Name)) return {"", Path}; - size_t Sep = Path.rfind('/', sizeof(UstarHeader::Name) + 1); + size_t Sep = Path.rfind('/', sizeof(UstarHeader::Prefix) + 1); if (Sep == StringRef::npos) return {"", Path}; return {Path.substr(0, Sep), Path.substr(Sep + 1)}; |