[PATCH] D41423: [Lex] Avoid out-of-bounds dereference in LexAngledStringLiteral.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 10 18:07:02 PST 2018


vsapsai marked an inline comment as done.
vsapsai added inline comments.


================
Comment at: clang/lib/Lex/Lexer.cpp:2026
+
+    if (C == 0) {
       NulCharacter = CurPtr-1;
----------------
vsapsai wrote:
> dexonsmith wrote:
> > vsapsai wrote:
> > > dexonsmith wrote:
> > > > Should this check still be skipped (in an `else if` of the `C == '\\'` check)?
> > > I agree it is behaviour change. `NulCharacter` is used to warn if you have null character in the string and I think it is worth warning even if it is preceded by the backslash. Therefore I think this check shouldn't be skipped after `C == '\\'` check. In practice I don't know how you can create a file with null character in its name and use it in inclusion directive.
> > Can you add a test for the behaviour change then?
> Added clang/test/Lexer/null-character-in-literal.c but struggling with Phabricator to display it as text file, not as binary. Guess those null characters can be confusing for some tools.
Added the test file at https://gist.github.com/vsapsai/d61a8a7d06356a18db26658acc0c4b25


https://reviews.llvm.org/D41423





More information about the cfe-commits mailing list