diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-23 23:55:43 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-23 23:55:43 +0000 |
commit | 205baf61c402a7ee190be99c29e655d3066e9c38 (patch) | |
tree | 4ac529400082c8e405c61ef6173246d1cbad8ace | |
parent | 6b815c87998bd7066079b842f1fd3279be655440 (diff) | |
download | bcm5719-llvm-205baf61c402a7ee190be99c29e655d3066e9c38.tar.gz bcm5719-llvm-205baf61c402a7ee190be99c29e655d3066e9c38.zip |
Fixe a buffer overflow problem which causes a crash
in a certain project. Need to have a permananent fix later
(FIXME added).
llvm-svn: 84980
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5d6d0ba3a15..e226f28c867 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2855,8 +2855,10 @@ QualType ASTContext::BuildByRefType(const char *DeclName, QualType Ty) { // FIXME: Move up static int UniqueBlockByRefTypeID = 0; - char Name[36]; + // FIXME. This is error prone. Luckinly stack-canary stuff caught it. + char Name[128]; sprintf(Name, "__Block_byref_%d_%s", ++UniqueBlockByRefTypeID, DeclName); + assert((strlen(Name) < sizeof(Name)) && "BuildByRefType - buffer overflow"); RecordDecl *T; T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(), &Idents.get(Name)); @@ -2904,8 +2906,10 @@ QualType ASTContext::getBlockParmType( llvm::SmallVector<const Expr *, 8> &BlockDeclRefDecls) { // FIXME: Move up static int UniqueBlockParmTypeID = 0; - char Name[36]; + // FIXME. This is error prone. Luckinly stack-canary stuff caught it. + char Name[128]; sprintf(Name, "__block_literal_%u", ++UniqueBlockParmTypeID); + assert((strlen(Name) < sizeof(Name)) && "getBlockParmType - buffer overflow"); RecordDecl *T; T = RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(), &Idents.get(Name)); |