[cfe-commits] r134404 - /cfe/trunk/lib/AST/Stmt.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Jul 5 04:13:37 PDT 2011
Author: d0k
Date: Tue Jul 5 06:13:37 2011
New Revision: 134404
URL: http://llvm.org/viewvc/llvm-project?rev=134404&view=rev
Log:
Don't overread the buffer when an %x escape in inline asm ends prematurely.
Tested by valgrind & Sema/asm.c.
Modified:
cfe/trunk/lib/AST/Stmt.cpp
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=134404&r1=134403&r2=134404&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Tue Jul 5 06:13:37 2011
@@ -366,6 +366,10 @@
// Handle %x4 and %x[foo] by capturing x as the modifier character.
char Modifier = '\0';
if (isalpha(EscapedChar)) {
+ if (CurPtr == StrEnd) { // Premature end.
+ DiagOffs = CurPtr-StrStart-1;
+ return diag::err_asm_invalid_escape;
+ }
Modifier = EscapedChar;
EscapedChar = *CurPtr++;
}
More information about the cfe-commits
mailing list