<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Mar 29, 2015 at 7:11 AM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: d0k<br>
Date: Sun Mar 29 09:11:37 2015<br>
New Revision: 233491<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=233491&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=233491&view=rev</a><br>
Log:<br>
[lex] Don't read past the end of the buffer<br>
<br>
While dereferencing ThisTokEnd is fine and we know that it's not in<br>
[a-zA-Z0-9_.], ThisTokEnd[1] is really past the end.<br>
<br>
Found by asan and with a little help from clang-fuzz.<br></blockquote><div><br></div><div>This effectively reverts r<span style="font-size:12.8000001907349px">191485, which was working around a miscompilation under MSVC. Perhaps we've stopped supporting the relevant versions of MSVC now?</span></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Added:<br>
cfe/trunk/test/Lexer/eof-number.c<br>
Modified:<br>
cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
<br>
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=233491&r1=233490&r2=233491&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=233491&r1=233490&r2=233491&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)<br>
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sun Mar 29 09:11:37 2015<br>
@@ -748,11 +748,11 @@ void NumericLiteralParser::ParseNumberSt<br>
s++;<br>
<br>
int c1 = s[0];<br>
- int c2 = s[1];<br>
<br>
// Handle a hex number like 0x1234.<br>
- if ((c1 == 'x' || c1 == 'X') && (isHexDigit(c2) || c2 == '.')) {<br>
+ if ((c1 == 'x' || c1 == 'X') && (isHexDigit(s[1]) || s[1] == '.')) {<br>
s++;<br>
+ assert(s < ThisTokEnd && "didn't maximally munch?");<br>
radix = 16;<br>
DigitsBegin = s;<br>
s = SkipHexDigits(s);<br>
@@ -804,7 +804,7 @@ void NumericLiteralParser::ParseNumberSt<br>
}<br>
<br>
// Handle simple binary numbers 0b01010<br>
- if ((c1 == 'b' || c1 == 'B') && (c2 == '0' || c2 == '1')) {<br>
+ if ((c1 == 'b' || c1 == 'B') && (s[1] == '0' || s[1] == '1')) {<br>
// 0b101010 is a C++1y / GCC extension.<br>
PP.Diag(TokLoc,<br>
PP.getLangOpts().CPlusPlus14<br>
@@ -813,6 +813,7 @@ void NumericLiteralParser::ParseNumberSt<br>
? diag::ext_binary_literal_cxx14<br>
: diag::ext_binary_literal);<br>
++s;<br>
+ assert(s < ThisTokEnd && "didn't maximally munch?");<br>
radix = 2;<br>
DigitsBegin = s;<br>
s = SkipBinaryDigits(s);<br>
<br>
Added: cfe/trunk/test/Lexer/eof-number.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/eof-number.c?rev=233491&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/eof-number.c?rev=233491&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Lexer/eof-number.c (added)<br>
+++ cfe/trunk/test/Lexer/eof-number.c Sun Mar 29 09:11:37 2015<br>
@@ -0,0 +1,9 @@<br>
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wnewline-eof<br>
+// vim: set binary noeol:<br>
+<br>
+// This file intentionally ends without a \n on the last line. Make sure your<br>
+// editor doesn't add one.<br>
+<br>
+// expected-error@+2{{unterminated conditional directive}}<br>
+// expected-warning@+1{{no newline at end of file}}<br>
+#if 0<br>
\ No newline at end of file<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>