<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang trunk r261461+ fails to compile on some platforms (including Snow Leopard) due to strnlen usage"
   href="https://llvm.org/bugs/show_bug.cgi?id=27714">27714</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang trunk r261461+ fails to compile on some platforms (including Snow Leopard) due to strnlen usage
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jeremyhu@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>strnlen() is used unconditionally, but it is not available on all supported
platforms.

trunk/tools/clang/lib/Lex/HeaderMap.cpp:158:18: error: use of undeclared
identifier 'strnlen'
  unsigned Len = strnlen(Data, MaxLen);
                 ^
1 error generated.

---

Regression introduced by:

commit 839cd13b65d802f06276ff88d234419c38a44199
Author: Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>>
Date:   Sun Feb 21 00:14:36 2016 +0000

    Lex: Never overflow the file in HeaderMap::lookupFilename()

    If a header map file is corrupt, the strings in the string table may not
    be null-terminated.  The logic here previously relied on `MemoryBuffer`
    always being null-terminated, but this isn't actually guaranteed by the
    class AFAICT.  Moreover, we're seeing a lot of crash traces at calls to
    `strlen()` inside of `lookupFilename()`, so something is going wrong
    there.

    Instead, use `strnlen()` to get the length, and check for corruption.

    Also remove code paths that could call `StringRef(nullptr)`.  r261459
    made these rather obvious (although they'd been there all along).

    git-svn-id: <a href="https://llvm.org/svn/llvm-project/cfe/trunk@261461">https://llvm.org/svn/llvm-project/cfe/trunk@261461</a>
91177308-0d34-0410-b5e6-96231b3b80d8</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>