Fixe a buffer overflow problem which causes a crash

in a certain project. Need to have a permananent fix later
(FIXME added).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84980 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2009-10-23 23:55:43 +00:00
Родитель 33642df300
Коммит 60aeaddb12
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -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));