Skip to content

Commit e035a2d

Browse files
pleathMikeHolman
authored andcommitted
[CVE-2018-8459] Edge - ChakraCore Type Confusion Vulnerability -
1 parent 07a72e2 commit e035a2d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/Runtime/Types/PathTypeHandler.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,8 +2563,9 @@ namespace Js
25632563
Assert(IsObjectHeaderInlinedTypeHandler());
25642564

25652565
// Clone the type Path here to evolve separately
2566+
Recycler * recycler = library->GetRecycler();
25662567
uint16 pathLength = GetPathLength();
2567-
TypePath * clonedPath = TypePath::New(library->GetRecycler(), pathLength);
2568+
TypePath * clonedPath = TypePath::New(recycler, pathLength);
25682569

25692570
ObjectSlotAttributes *attributes = this->GetAttributeArray();
25702571
for (PropertyIndex i = 0; i < pathLength; i++)
@@ -2597,12 +2598,29 @@ namespace Js
25972598
}
25982599
else
25992600
{
2601+
uint8 newTypePathSize = clonedPath->GetPathSize();
2602+
2603+
ObjectSlotAttributes * newAttributes = RecyclerNewArrayLeaf(recycler, ObjectSlotAttributes, newTypePathSize);
2604+
memcpy(newAttributes, attributes, sizeof(ObjectSlotAttributes) * newTypePathSize);
2605+
2606+
PathTypeSetterSlotIndex * setters = GetSetterSlots();
2607+
PathTypeSetterSlotIndex * newSetters;
2608+
if (setters == nullptr)
2609+
{
2610+
newSetters = nullptr;
2611+
}
2612+
else
2613+
{
2614+
newSetters = RecyclerNewArrayLeaf(recycler, PathTypeSetterSlotIndex, newTypePathSize);
2615+
memcpy(newSetters, setters, sizeof(PathTypeSetterSlotIndex) * newTypePathSize);
2616+
}
2617+
26002618
clonedTypeHandler =
26012619
PathTypeHandlerWithAttr::New(
26022620
library->GetScriptContext(),
26032621
clonedPath,
2604-
attributes,
2605-
GetSetterSlots(),
2622+
newAttributes,
2623+
newSetters,
26062624
GetSetterCount(),
26072625
GetPathLength(),
26082626
static_cast<PropertyIndex>(GetSlotCapacity()),

0 commit comments

Comments
 (0)