[PATCH] D38149: Fix off-by-one error in TarWriter.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 12:54:56 PDT 2017


ruiu created this revision.
Herald added a subscriber: hiraditya.

The tar format originally supported up to 99 byte filename. The two
extensions are proposed later: Ustar or PAX.

In the UStar extension, a pathanme is split at a '/' and its "prefix"
and "suffix" are stored in different locations in the tar header. Since
"prefix" can be up to 155 byte, it can represent up to 254 byte
filename (but exact limit depends on the location of '/' character in
a pathname.)

Our TarWriter first attempt to use UStar extension and then fallback to
PAX extension.

But there's a bug in UStar header creation. "Suffix" part must be a NUL-
terminated string, but we didn't handle it correctly. As a result, if
your filename just 100 characters long, the last character was droppped.

This patch fixes the issue.


https://reviews.llvm.org/D38149

Files:
  llvm/lib/Support/TarWriter.cpp
  llvm/unittests/Support/TarWriterTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38149.116249.patch
Type: text/x-patch
Size: 4585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/bfd727ac/attachment.bin>


More information about the llvm-commits mailing list