Skip to content

Commit

Permalink
[CVE-2018-8459] Edge - ChakraCore Type Confusion Vulnerability -
Browse files Browse the repository at this point in the history
  • Loading branch information
pleath authored and MikeHolman committed Sep 11, 2018
1 parent 07a72e2 commit e035a2d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/Runtime/Types/PathTypeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,8 +2563,9 @@ namespace Js
Assert(IsObjectHeaderInlinedTypeHandler());

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

ObjectSlotAttributes *attributes = this->GetAttributeArray();
for (PropertyIndex i = 0; i < pathLength; i++)
Expand Down Expand Up @@ -2597,12 +2598,29 @@ namespace Js
}
else
{
uint8 newTypePathSize = clonedPath->GetPathSize();

ObjectSlotAttributes * newAttributes = RecyclerNewArrayLeaf(recycler, ObjectSlotAttributes, newTypePathSize);
memcpy(newAttributes, attributes, sizeof(ObjectSlotAttributes) * newTypePathSize);

PathTypeSetterSlotIndex * setters = GetSetterSlots();
PathTypeSetterSlotIndex * newSetters;
if (setters == nullptr)
{
newSetters = nullptr;
}
else
{
newSetters = RecyclerNewArrayLeaf(recycler, PathTypeSetterSlotIndex, newTypePathSize);
memcpy(newSetters, setters, sizeof(PathTypeSetterSlotIndex) * newTypePathSize);
}

clonedTypeHandler =
PathTypeHandlerWithAttr::New(
library->GetScriptContext(),
clonedPath,
attributes,
GetSetterSlots(),
newAttributes,
newSetters,
GetSetterCount(),
GetPathLength(),
static_cast<PropertyIndex>(GetSlotCapacity()),
Expand Down

0 comments on commit e035a2d

Please sign in to comment.