[PATCH] D46527: Object: Find terminator correctly when getting long filenames from GNU archives

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 17:08:55 PDT 2018


inglorion added a comment.

Digging a bit deeper into this, I don't understand how this breaks. The crash indicates that we're running off the end of the file while reading from the long file name table while looking for a newline that isn't there. However, we seem to always create archives with the long file name table before any member that references it, and both GNU ar and llvm-ar will reject archives that are not structured that way. This means that there must be at least one member after the long file name table. Since the record at the beginning of a member ends in a newline (see ArchiveWriter::printRestOfMemberHeader), this means there must always be a newline between the end of the long file name table and the end of the file. For archives we write, every long file name including the last is followed by a newline (see ArchiveWriter::addToStringTable), so the newline we find should always be in memory we can read and always be at the end of the long file name we're looking at.

@hans, do you happen to have an archive that causes the crash without this fix having been applied? If so, I can take a look at that and see how I can turn it into a test case. If not, I'll just be happy that the fix is in and move on.


Repository:
  rL LLVM

https://reviews.llvm.org/D46527





More information about the llvm-commits mailing list