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

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 13:31:58 PST 2017


Ah, I think you are right. I'll fix it with a test to verify.

On Mon, Jan 9, 2017 at 1:25 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/5632aa46/attachment.html>


More information about the llvm-commits mailing list