[llvm] r291340 - TarWriter: Use Ustar header's "prefix" field to store long filenames.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 13:25:19 PST 2017


Rui Ueyama <ruiu at google.com> writes:

> On Mon, Jan 9, 2017 at 12:58 PM, Rafael Avila de Espindola <
> rafael.espindola at gmail.com> wrote:
>
>> > +// Returns true if a given path can be stored to a Ustar header
>> > +// without the PAX extension.
>> > +static bool fitInUstar(StringRef Path) {
>> > +  StringRef Prefix;
>> > +  StringRef Name;
>> > +  std::tie(Prefix, Name) = splitPath(Path);
>> > +  return Name.size() <= sizeof(UstarHeader::Name);
>>
>> Don't you have to check sizeof(UstarHeader::Prefix) too?
>>
>
> No, I don't, because that's guaranteed to be satisfied. If a path is too
> long, only Name part can exceed its maximum length.

I think I get it, but then shouldn't

  size_t Sep = Path.rfind('/', sizeof(UstarHeader::Name) + 1);

be

  size_t Sep = Path.rfind('/', sizeof(UstarHeader::Prefix) + 1);

The idea being that you start with the largest possible prefix and walk
backwards until you find a '/'?

Cheers,
Rafael


More information about the llvm-commits mailing list