⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 187313 in webkit


Ignore:
Timestamp:
Jul 24, 2015, 12:54:15 AM (11 years ago)
Author:
matthew_hanson@apple.com
Message:

Merge r187189. rdar://problem/21567767

Location:
branches/safari-601.1-branch
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-601.1-branch/LayoutTests/ChangeLog

    r187307 r187313  
     12015-07-24  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r187189. rdar://problem/21567767
     4
     5    2015-07-22  Dean Jackson  <dino@apple.com>
     6
     7            Out of bounds in WebGLRenderingContext::simulateVertexAttrib0
     8            https://bugs.webkit.org/show_bug.cgi?id=147176
     9            <rdar://problem/21567767>
     10
     11            Reviewed by Oliver Hunt.
     12
     13            * fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays-expected.txt: Added.
     14            * fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html: Added.
     15
    1162015-07-24  Lucas Forschler  <lforschler@apple.com>
    217
  • branches/safari-601.1-branch/Source/WebCore/ChangeLog

    r187311 r187313  
     12015-07-24  Matthew Hanson  <matthew_hanson@apple.com>
     2
     3        Merge r187189. rdar://problem/21567767
     4
     5    2015-07-22  Dean Jackson  <dino@apple.com>
     6
     7            Out of bounds in WebGLRenderingContext::simulateVertexAttrib0
     8            https://bugs.webkit.org/show_bug.cgi?id=147176
     9            <rdar://problem/21567767>
     10
     11            Reviewed by Oliver Hunt.
     12
     13            Test: fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html
     14
     15            Add overflow checking for the drawing calls, specifically the way
     16            they may simulate vertexAttrib0.
     17
     18            * html/canvas/WebGLRenderingContextBase.cpp:
     19            (WebCore::WebGLRenderingContextBase::validateDrawArrays): Call new validation method.
     20            (WebCore::WebGLRenderingContextBase::validateDrawElements): Ditto.
     21            (WebCore::WebGLRenderingContextBase::validateSimulatedVertexAttrib0): New method that
     22            validates the parameters used to create the simulated attribute.
     23            (WebCore::WebGLRenderingContextBase::simulateVertexAttrib0): No need to do overflow
     24            checking here now that the validation method does it for us.
     25            (WebCore::WebGLRenderingContextBase::validateVertexAttributes): Deleted.
     26            * html/canvas/WebGLRenderingContextBase.h: Add new validation method.
     27
    1282015-07-24  Matthew Hanson  <matthew_hanson@apple.com>
    229
  • branches/safari-601.1-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r186384 r187313  
    17091709        return true;
    17101710
    1711 
    17121711    // Look in each consumed vertex attrib (by the current program).
    17131712    bool sawNonInstancedAttrib = false;
     
    17941793            return false;
    17951794        }
     1795        if (!validateSimulatedVertexAttrib0(checkedSum.unsafeGet() - 1)) {
     1796            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attempt to access outside the bounds of the simulated vertexAttrib0 array");
     1797            return false;
     1798        }
    17961799    } else {
    17971800        if (!validateVertexAttributes(0)) {
     
    18741877            }
    18751878        }
     1879
     1880        if (!validateSimulatedVertexAttrib0(numElements)) {
     1881            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attempt to access outside the bounds of the simulated vertexAttrib0 array");
     1882            return false;
     1883        }
     1884
    18761885    } else {
    18771886        if (!validateVertexAttributes(0)) {
     
    46704679}
    46714680
     4681bool WebGLRenderingContextBase::validateSimulatedVertexAttrib0(GC3Dsizei numVertex)
     4682{
     4683    if (numVertex < 0)
     4684        return false;
     4685
     4686    if (!m_currentProgram)
     4687        return true;
     4688
     4689    bool usingVertexAttrib0 = m_currentProgram->isUsingVertexAttrib0();
     4690    if (!usingVertexAttrib0)
     4691        return true;
     4692
     4693    auto& state = m_boundVertexArrayObject->getVertexAttribState(0);
     4694    if (state.enabled)
     4695        return true;
     4696
     4697    Checked<GC3Dsizei, RecordOverflow> bufferSize(numVertex);
     4698    bufferSize += 1;
     4699    bufferSize *= Checked<GC3Dsizei>(4);
     4700    Checked<GC3Dsizeiptr, RecordOverflow> bufferDataSize(bufferSize);
     4701    bufferDataSize *= Checked<GC3Dsizeiptr>(sizeof(GC3Dfloat));
     4702    return !bufferDataSize.hasOverflowed();
     4703}
     4704
    46724705bool WebGLRenderingContextBase::simulateVertexAttrib0(GC3Dsizei numVertex)
    46734706{
    4674     const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);
    4675     const VertexAttribValue& attribValue = m_vertexAttribValue[0];
    46764707    if (!m_currentProgram)
    46774708        return false;
     
    46794710    if (usingVertexAttrib0)
    46804711        m_vertexAttrib0UsedBefore = true;
     4712
     4713    auto& state = m_boundVertexArrayObject->getVertexAttribState(0);
    46814714    if (state.enabled && usingVertexAttrib0)
    46824715        return false;
     
    46854718    m_vertexAttrib0UsedBefore = true;
    46864719    m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_vertexAttrib0Buffer->object());
    4687     Checked<GC3Dsizeiptr, RecordOverflow> bufferDataSize(numVertex);
    4688     bufferDataSize += 1;
    4689     bufferDataSize *= Checked<GC3Dsizeiptr, RecordOverflow>(4 * sizeof(GC3Dfloat));
    4690     if (bufferDataSize.hasOverflowed())
    4691         return false;
     4720
     4721    Checked<GC3Dsizei> bufferSize(numVertex);
     4722    bufferSize += 1;
     4723    bufferSize *= Checked<GC3Dsizei>(4);
     4724
     4725    Checked<GC3Dsizeiptr> bufferDataSize(bufferSize);
     4726    bufferDataSize *= Checked<GC3Dsizeiptr>(sizeof(GC3Dfloat));
     4727
    46924728    if (bufferDataSize.unsafeGet() > m_vertexAttrib0BufferSize) {
    46934729        m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, bufferDataSize.unsafeGet(), 0, GraphicsContext3D::DYNAMIC_DRAW);
     
    46954731        m_forceAttrib0BufferRefill = true;
    46964732    }
     4733
     4734    auto& attribValue = m_vertexAttribValue[0];
     4735
    46974736    if (usingVertexAttrib0
    46984737        && (m_forceAttrib0BufferRefill
     
    47014740            || attribValue.value[2] != m_vertexAttrib0BufferValue[2]
    47024741            || attribValue.value[3] != m_vertexAttrib0BufferValue[3])) {
    4703         auto bufferData = std::make_unique<GC3Dfloat[]>((numVertex + 1) * 4);
     4742
     4743        auto bufferData = std::make_unique<GC3Dfloat[]>(bufferSize.unsafeGet());
    47044744        for (GC3Dsizei ii = 0; ii < numVertex + 1; ++ii) {
    47054745            bufferData[ii * 4] = attribValue.value[0];
  • branches/safari-601.1-branch/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r182544 r187313  
    791791    bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted);
    792792
    793     // Helpers for simulating vertexAttrib0
     793    // Helpers for simulating vertexAttrib0.
    794794    void initVertexAttrib0();
    795795    bool simulateVertexAttrib0(GC3Dsizei numVertex);
     796    bool validateSimulatedVertexAttrib0(GC3Dsizei numVertex);
    796797    void restoreStatesAfterVertexAttrib0Simulation();
    797798
Note: See TracChangeset for help on using the changeset viewer.