Skip to content

Commit

Permalink
[CVE-2018-0994] Edge - Submit a use after free bug to Edge - 360Vulcan
Browse files Browse the repository at this point in the history
  • Loading branch information
akroshg authored and rajatd committed Apr 10, 2018
1 parent 91dc6f8 commit 0578ca5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/Runtime/Library/JavascriptArray.cpp
Expand Up @@ -2090,6 +2090,13 @@ namespace Js
// Code below has potential to throw due to OOM or SO. Just FailFast on those cases
AutoDisableInterrupt failFastError(scriptContext->GetThreadContext());

#if defined(TARGET_32)
if (fArray->head && (fArray->head->size >= SparseArraySegmentBase::INLINE_CHUNK_SIZE / shrinkFactor))
{
CopyHeadIfInlinedHeadSegment<double>(fArray, recycler);
}
#endif

for (seg = fArray->head; seg; seg = nextSeg)
{
nextSeg = seg->next;
Expand Down Expand Up @@ -5320,6 +5327,8 @@ namespace Js
AnalysisAssert(array->head);
SparseArraySegment<T>* newHeadSeg = array->ReallocNonLeafSegment((SparseArraySegment<T>*)PointerValue(array->head), array->head->next);
array->head = newHeadSeg;
array->InvalidateLastUsedSegment();
array->ClearSegmentMap();
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Runtime/Library/JavascriptArray.h
Expand Up @@ -549,6 +549,8 @@ namespace Js
void SetHeadAndLastUsedSegment(SparseArraySegmentBase * segment);
void SetLastUsedSegment(SparseArraySegmentBase * segment);
bool HasSegmentMap() const;
template<typename T>
static void CopyHeadIfInlinedHeadSegment(JavascriptArray *array, Recycler *recycler);

private:
void SetSegmentMap(SegmentBTreeRoot * segmentMap);
Expand Down Expand Up @@ -584,8 +586,6 @@ namespace Js

virtual int32 HeadSegmentIndexOfHelper(Var search, uint32 &fromIndex, uint32 toIndex, bool includesAlgorithm, ScriptContext * scriptContext);

template<typename T>
static void CopyHeadIfInlinedHeadSegment(JavascriptArray *array, Recycler *recycler);
template<typename T>
static void ReallocateNonLeafLastSegmentIfLeaf(JavascriptArray * arr, Recycler * recycler);

Expand Down

0 comments on commit 0578ca5

Please sign in to comment.