<div dir="ltr">Ah, I think you are right. I'll fix it with a test to verify.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 9, 2017 at 1:25 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> writes:<br>
<br>
> On Mon, Jan 9, 2017 at 12:58 PM, Rafael Avila de Espindola <<br>
> <a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
><br>
>> > +// Returns true if a given path can be stored to a Ustar header<br>
>> > +// without the PAX extension.<br>
>> > +static bool fitInUstar(StringRef Path) {<br>
>> > +  StringRef Prefix;<br>
>> > +  StringRef Name;<br>
>> > +  std::tie(Prefix, Name) = splitPath(Path);<br>
>> > +  return Name.size() <= sizeof(UstarHeader::Name);<br>
>><br>
>> Don't you have to check sizeof(UstarHeader::Prefix) too?<br>
>><br>
><br>
> No, I don't, because that's guaranteed to be satisfied. If a path is too<br>
> long, only Name part can exceed its maximum length.<br>
<br>
</div></div>I think I get it, but then shouldn't<br>
<span class=""><br>
  size_t Sep = Path.rfind('/', sizeof(UstarHeader::Name) + 1);<br>
<br>
</span>be<br>
<br>
  size_t Sep = Path.rfind('/', sizeof(UstarHeader::Prefix) + 1);<br>
<br>
The idea being that you start with the largest possible prefix and walk<br>
backwards until you find a '/'?<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div>