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 | e9d17545bc5922f5eda60a65c3fba88ec36fc1f5 (patch) | |
| tree | 12f9eac28af4cb0634a7a1b0d391bb68295cbab1 /llvm/lib | |
| parent | be92d5e930625470980b4213369658c628f2f310 (diff) | |
| download | bcm5719-llvm-e9d17545bc5922f5eda60a65c3fba88ec36fc1f5.tar.gz bcm5719-llvm-e9d17545bc5922f5eda60a65c3fba88ec36fc1f5.zip | |
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.
llvm-svn: 291494
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Support/TarWriter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/TarWriter.cpp b/llvm/lib/Support/TarWriter.cpp index 58abffcca55..f06abf46cce 100644 --- a/llvm/lib/Support/TarWriter.cpp +++ b/llvm/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)}; |

