From PR6228:
authorChris Lattner <sabre@nondot.org>
Thu, 4 Feb 2010 06:19:43 +0000 (06:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 4 Feb 2010 06:19:43 +0000 (06:19 +0000)
"Attached patch removes the extra NUL bytes from the output and changes
test/Archive/MacOSX.toc from a binary to a text file (removes
svn:mime-type=application/octet-stream and adds svn:eol-style=native).  I can't
figure out how to get SVN to include the new contents of the file in the patch
so I'm attaching it separately."

Patch by James Abbatiello!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95292 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Archive/ArchiveReader.cpp
test/Archive/MacOSX.toc

index a0c42b50167e53652c2f384272086b6758e6baf7..3ef15d25d6900b5e04ac6a59bbf4e57aa8e56417 100644 (file)
@@ -120,7 +120,8 @@ Archive::parseMemberHeader(const char*& At, const char* End, std::string* error)
       if (Hdr->name[1] == '1' && Hdr->name[2] == '/') {
         if (isdigit(Hdr->name[3])) {
           unsigned len = atoi(&Hdr->name[3]);
-          pathname.assign(At, len);
+          const char *nulp = (const char *)memchr(At, '\0', len);
+          pathname.assign(At, nulp != 0 ? nulp - At : len);
           At += len;
           MemberSize -= len;
           flags |= ArchiveMember::HasLongFilenameFlag;
index 61cbd3b2a070a1f46912b650ae839c16da3bd3ab..f971df73325c7a2be490eade9acca1f24e6bfd3e 100644 (file)
Binary files a/test/Archive/MacOSX.toc and b/test/Archive/MacOSX.toc differ