소스 검색

[CVE-2018-0775] Deferred parsing makes wrong scopes #2 - Google, Inc.

Paul Leathers 8 년 전
부모
커밋
ee5ac64f96
3개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      lib/Runtime/ByteCode/ByteCodeGenerator.cpp
  2. 11 0
      test/es6/function-expr-capture2.js
  3. 6 0
      test/es6/rlexe.xml

+ 5 - 0
lib/Runtime/ByteCode/ByteCodeGenerator.cpp

@@ -1423,6 +1423,11 @@ FuncInfo * ByteCodeGenerator::StartBindFunction(const char16 *name, uint nameLen
         sym->SetPosition(parseableFunctionInfo->GetOrAddPropertyIdTracked(sym->GetName()));
 
         pnode->sxFnc.SetFuncSymbol(sym);
+
+        if (funcExprScope->GetIsObject())
+        {
+            funcExprScope->SetMustInstantiate(true);
+        }
     }
 
     Scope *paramScope = pnode->sxFnc.pnodeScopes ? pnode->sxFnc.pnodeScopes->sxBlock.scope : nullptr;

+ 11 - 0
test/es6/function-expr-capture2.js

@@ -0,0 +1,11 @@
+eval(
+    '(function f() {' +
+    '     with({}) {' +
+    '         (function () {' +
+    '             return f;' +
+    '         })();' +
+    '     }' +
+    ' }());'
+);
+
+WScript.Echo('pass');

+ 6 - 0
test/es6/rlexe.xml

@@ -1521,4 +1521,10 @@
     <files>function-expr-capture.js</files>
   </default>
 </test>
+<test>
+  <default>
+    <files>function-expr-capture2.js</files>
+    <compile-flags>-force:deferparse</compile-flags>
+  </default>
+</test>
 </regress-exe>