Changeset 187189 in webkit
- Timestamp:
- Jul 22, 2015, 2:55:48 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays-expected.txt (added)
-
LayoutTests/fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (modified) (8 diffs)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r187185 r187189 1 2015-07-22 Dean Jackson <dino@apple.com> 2 3 Out of bounds in WebGLRenderingContext::simulateVertexAttrib0 4 https://bugs.webkit.org/show_bug.cgi?id=147176 5 <rdar://problem/21567767> 6 7 Reviewed by Oliver Hunt. 8 9 * fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays-expected.txt: Added. 10 * fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html: Added. 11 1 12 2015-07-22 Joseph Pecoraro <pecoraro@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r187185 r187189 1 2015-07-22 Dean Jackson <dino@apple.com> 2 3 Out of bounds in WebGLRenderingContext::simulateVertexAttrib0 4 https://bugs.webkit.org/show_bug.cgi?id=147176 5 <rdar://problem/21567767> 6 7 Reviewed by Oliver Hunt. 8 9 Test: fast/canvas/webgl/out-of-bounds-simulated-vertexAttrib0-drawArrays.html 10 11 Add overflow checking for the drawing calls, specifically the way 12 they may simulate vertexAttrib0. 13 14 * html/canvas/WebGLRenderingContextBase.cpp: 15 (WebCore::WebGLRenderingContextBase::validateDrawArrays): Call new validation method. 16 (WebCore::WebGLRenderingContextBase::validateDrawElements): Ditto. 17 (WebCore::WebGLRenderingContextBase::validateSimulatedVertexAttrib0): New method that 18 validates the parameters used to create the simulated attribute. 19 (WebCore::WebGLRenderingContextBase::simulateVertexAttrib0): No need to do overflow 20 checking here now that the validation method does it for us. 21 (WebCore::WebGLRenderingContextBase::validateVertexAttributes): Deleted. 22 * html/canvas/WebGLRenderingContextBase.h: Add new validation method. 23 1 24 2015-07-22 Joseph Pecoraro <pecoraro@apple.com> 2 25 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r186384 r187189 1709 1709 return true; 1710 1710 1711 1712 1711 // Look in each consumed vertex attrib (by the current program). 1713 1712 bool sawNonInstancedAttrib = false; … … 1794 1793 return false; 1795 1794 } 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 } 1796 1799 } else { 1797 1800 if (!validateVertexAttributes(0)) { … … 1874 1877 } 1875 1878 } 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 1876 1885 } else { 1877 1886 if (!validateVertexAttributes(0)) { … … 4670 4679 } 4671 4680 4681 bool 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 4672 4705 bool WebGLRenderingContextBase::simulateVertexAttrib0(GC3Dsizei numVertex) 4673 4706 { 4674 const WebGLVertexArrayObjectBase::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(0);4675 const VertexAttribValue& attribValue = m_vertexAttribValue[0];4676 4707 if (!m_currentProgram) 4677 4708 return false; … … 4679 4710 if (usingVertexAttrib0) 4680 4711 m_vertexAttrib0UsedBefore = true; 4712 4713 auto& state = m_boundVertexArrayObject->getVertexAttribState(0); 4681 4714 if (state.enabled && usingVertexAttrib0) 4682 4715 return false; … … 4685 4718 m_vertexAttrib0UsedBefore = true; 4686 4719 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 4692 4728 if (bufferDataSize.unsafeGet() > m_vertexAttrib0BufferSize) { 4693 4729 m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, bufferDataSize.unsafeGet(), 0, GraphicsContext3D::DYNAMIC_DRAW); … … 4695 4731 m_forceAttrib0BufferRefill = true; 4696 4732 } 4733 4734 auto& attribValue = m_vertexAttribValue[0]; 4735 4697 4736 if (usingVertexAttrib0 4698 4737 && (m_forceAttrib0BufferRefill … … 4701 4740 || attribValue.value[2] != m_vertexAttrib0BufferValue[2] 4702 4741 || 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()); 4704 4744 for (GC3Dsizei ii = 0; ii < numVertex + 1; ++ii) { 4705 4745 bufferData[ii * 4] = attribValue.value[0]; -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r182544 r187189 791 791 bool checkObjectToBeBound(const char* functionName, WebGLObject*, bool& deleted); 792 792 793 // Helpers for simulating vertexAttrib0 793 // Helpers for simulating vertexAttrib0. 794 794 void initVertexAttrib0(); 795 795 bool simulateVertexAttrib0(GC3Dsizei numVertex); 796 bool validateSimulatedVertexAttrib0(GC3Dsizei numVertex); 796 797 void restoreStatesAfterVertexAttrib0Simulation(); 797 798
Note:
See TracChangeset
for help on using the changeset viewer.