Skip to content

Commit 227fc37

Browse files
atulkattiAtul Katti
authored andcommitted
[CVE-2018-8279] Edge - Chakra: Parameter scope parsing bug - Google, Inc.
1 parent 64cd4d2 commit 227fc37

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Parser/Parse.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,7 +6311,9 @@ void Parser::ParseFncName(ParseNodeFnc * pnodeFnc, ushort flags, IdentPtr* pFncN
63116311
pnodeFnc->pnodeName = nullptr;
63126312

63136313
if ((m_token.tk != tkID || flags & fFncNoName)
6314-
&& (IsStrictMode() || (pnodeFnc->IsGenerator()) || m_token.tk != tkYIELD || fDeclaration)) // Function expressions can have the name yield even inside generator functions
6314+
&& (IsStrictMode() || fDeclaration
6315+
|| pnodeFnc->IsGenerator() || pnodeFnc->IsAsync()
6316+
|| (m_token.tk != tkYIELD && m_token.tk != tkAWAIT))) // Function expressions can have the name yield/await even inside generator/async functions
63156317
{
63166318
if (fDeclaration ||
63176319
m_token.IsReservedWord()) // For example: var x = (function break(){});
@@ -6321,7 +6323,7 @@ void Parser::ParseFncName(ParseNodeFnc * pnodeFnc, ushort flags, IdentPtr* pFncN
63216323
return;
63226324
}
63236325

6324-
Assert(m_token.tk == tkID || (m_token.tk == tkYIELD && !fDeclaration));
6326+
Assert(m_token.tk == tkID || (m_token.tk == tkYIELD && !fDeclaration) || (m_token.tk == tkAWAIT && !fDeclaration));
63256327

63266328
if (IsStrictMode())
63276329
{
@@ -8461,15 +8463,17 @@ ParseNodePtr Parser::ParseExpr(int oplMin,
84618463
// binding operator, be it unary or binary.
84628464
Error(ERRsyntax);
84638465
}
8464-
if (m_currentScope->GetScopeType() == ScopeType_Parameter)
8466+
if (m_currentScope->GetScopeType() == ScopeType_Parameter
8467+
|| (m_currentScope->GetScopeType() == ScopeType_Block && m_currentScope->GetEnclosingScope()->GetScopeType() == ScopeType_Parameter)) // Check whether this is a class definition inside param scope
84658468
{
84668469
Error(ERRsyntax);
84678470
}
84688471
}
84698472
else if (nop == knopAwait)
84708473
{
84718474
if (!this->GetScanner()->AwaitIsKeywordRegion() ||
8472-
m_currentScope->GetScopeType() == ScopeType_Parameter)
8475+
m_currentScope->GetScopeType() == ScopeType_Parameter ||
8476+
(m_currentScope->GetScopeType() == ScopeType_Block && m_currentScope->GetEnclosingScope()->GetScopeType() == ScopeType_Parameter)) // Check whether this is a class definition inside param scope
84738477
{
84748478
// As with the 'yield' keyword, the case where 'await' is scanned as a keyword (tkAWAIT)
84758479
// but the scanner is not treating await as a keyword (!this->GetScanner()->AwaitIsKeyword())

0 commit comments

Comments
 (0)