[llvm-bugs] [Bug 27714] New: clang trunk r261461+ fails to compile on some platforms (including Snow Leopard) due to strnlen usage
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 11 08:49:23 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27714
Bug ID: 27714
Summary: clang trunk r261461+ fails to compile on some
platforms (including Snow Leopard) due to strnlen
usage
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: jeremyhu at apple.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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 <dexonsmith at apple.com>
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: https://llvm.org/svn/llvm-project/cfe/trunk@261461
91177308-0d34-0410-b5e6-96231b3b80d8
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160511/6bb3bdd7/attachment.html>
More information about the llvm-bugs
mailing list