r362067 - asm goto: fix out-of-bounds read of Constraints after rC362045

Fāng-ruì Sòng via cfe-commits cfe-commits at lists.llvm.org
Thu May 30 03:03:18 PDT 2019


You beat me to it.. Reverted

On Thu, May 30, 2019 at 5:41 PM Benjamin Kramer <benny.kra at gmail.com> wrote:

> Is this still necessary after r362062?
>
> On Thu, May 30, 2019 at 10:00 AM Fangrui Song via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: maskray
>> Date: Thu May 30 01:03:02 2019
>> New Revision: 362067
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=362067&view=rev
>> Log:
>> asm goto: fix out-of-bounds read of Constraints after rC362045
>>
>> When parsing goto labels, Names and Exprs are expanded but Constraints
>> is not, this may cause a out-of-bounds read later in:
>>
>> // GCCAsmStmt::GCCAsmStmt
>> // `constraints` has only `NumExprs - NumLabels` elements
>>   Constraints = new (C) StringLiteral*[NumExprs];
>>   std::copy(constraints, constraints + NumExprs, Constraints);
>>
>> Modified:
>>     cfe/trunk/lib/Parse/ParseStmtAsm.cpp
>>
>> Modified: cfe/trunk/lib/Parse/ParseStmtAsm.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmtAsm.cpp?rev=362067&r1=362066&r2=362067&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Parse/ParseStmtAsm.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseStmtAsm.cpp Thu May 30 01:03:02 2019
>> @@ -846,6 +846,7 @@ StmtResult Parser::ParseAsmStatement(boo
>>        ExprResult Res =
>>            Actions.ActOnAddrLabel(Tok.getLocation(), Tok.getLocation(),
>> LD);
>>        Exprs.push_back(Res.get());
>> +      Constraints.emplace_back();
>>        NumLabels++;
>>        ConsumeToken();
>>        if (!TryConsumeToken(tok::comma))
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>

-- 
宋方睿
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190530/3b5c40b8/attachment.html>


More information about the cfe-commits mailing list