Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
26b4b730
Commit
26b4b730
authored
Jul 09, 2013
by
Geoff Lang
Committed by
Al Patrick
Jul 26, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect against integer overflows in the VertexBuffer class by validating the reserved space.
Issue 444 Signed-off-by: Jamie Madil Signed-off-by: Shannon Woods Author: Geoff Lang
parent
8f037985
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
VertexBuffer.cpp
src/libGLESv2/renderer/VertexBuffer.cpp
+19
-3
VertexBuffer.h
src/libGLESv2/renderer/VertexBuffer.h
+2
-2
VertexDataManager.cpp
src/libGLESv2/renderer/VertexDataManager.cpp
+12
-3
No files found.
src/libGLESv2/renderer/VertexBuffer.cpp
View file @
26b4b730
...
@@ -125,14 +125,30 @@ int VertexBufferInterface::storeRawData(const void* data, unsigned int size)
...
@@ -125,14 +125,30 @@ int VertexBufferInterface::storeRawData(const void* data, unsigned int size)
return
oldWritePos
;
return
oldWritePos
;
}
}
void
VertexBufferInterface
::
reserveVertexSpace
(
const
gl
::
VertexAttribute
&
attribute
,
GLsizei
count
,
GLsizei
instances
)
bool
VertexBufferInterface
::
reserveVertexSpace
(
const
gl
::
VertexAttribute
&
attribute
,
GLsizei
count
,
GLsizei
instances
)
{
{
mReservedSpace
+=
mVertexBuffer
->
getSpaceRequired
(
attribute
,
count
,
instances
);
unsigned
int
requiredSpace
=
mVertexBuffer
->
getSpaceRequired
(
attribute
,
count
,
instances
);
// Protect against integer overflow
if
(
mReservedSpace
+
requiredSpace
<
mReservedSpace
)
{
return
false
;
}
mReservedSpace
+=
requiredSpace
;
return
true
;
}
}
void
VertexBufferInterface
::
reserveRawDataSpace
(
unsigned
int
size
)
bool
VertexBufferInterface
::
reserveRawDataSpace
(
unsigned
int
size
)
{
{
// Protect against integer overflow
if
(
mReservedSpace
+
size
<
mReservedSpace
)
{
return
false
;
}
mReservedSpace
+=
size
;
mReservedSpace
+=
size
;
return
true
;
}
}
VertexBuffer
*
VertexBufferInterface
::
getVertexBuffer
()
const
VertexBuffer
*
VertexBufferInterface
::
getVertexBuffer
()
const
...
...
src/libGLESv2/renderer/VertexBuffer.h
View file @
26b4b730
...
@@ -60,8 +60,8 @@ class VertexBufferInterface
...
@@ -60,8 +60,8 @@ class VertexBufferInterface
VertexBufferInterface
(
rx
::
Renderer
*
renderer
,
bool
dynamic
);
VertexBufferInterface
(
rx
::
Renderer
*
renderer
,
bool
dynamic
);
virtual
~
VertexBufferInterface
();
virtual
~
VertexBufferInterface
();
void
reserveVertexSpace
(
const
gl
::
VertexAttribute
&
attribute
,
GLsizei
count
,
GLsizei
instances
);
bool
reserveVertexSpace
(
const
gl
::
VertexAttribute
&
attribute
,
GLsizei
count
,
GLsizei
instances
);
void
reserveRawDataSpace
(
unsigned
int
size
);
bool
reserveRawDataSpace
(
unsigned
int
size
);
unsigned
int
getBufferSize
()
const
;
unsigned
int
getBufferSize
()
const
;
...
...
src/libGLESv2/renderer/VertexDataManager.cpp
View file @
26b4b730
...
@@ -116,12 +116,18 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
...
@@ -116,12 +116,18 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
if
(
staticBuffer
->
getBufferSize
()
==
0
)
if
(
staticBuffer
->
getBufferSize
()
==
0
)
{
{
int
totalCount
=
elementsInBuffer
(
attribs
[
i
],
buffer
->
size
());
int
totalCount
=
elementsInBuffer
(
attribs
[
i
],
buffer
->
size
());
staticBuffer
->
reserveVertexSpace
(
attribs
[
i
],
totalCount
,
0
);
if
(
!
staticBuffer
->
reserveVertexSpace
(
attribs
[
i
],
totalCount
,
0
))
{
return
GL_OUT_OF_MEMORY
;
}
}
}
}
}
else
else
{
{
mStreamingBuffer
->
reserveVertexSpace
(
attribs
[
i
],
count
,
instances
);
if
(
!
mStreamingBuffer
->
reserveVertexSpace
(
attribs
[
i
],
count
,
instances
))
{
return
GL_OUT_OF_MEMORY
;
}
}
}
}
}
}
}
...
@@ -217,7 +223,10 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
...
@@ -217,7 +223,10 @@ GLenum VertexDataManager::prepareVertexData(const gl::VertexAttribute attribs[],
mCurrentValue
[
i
][
3
]
!=
attribs
[
i
].
mCurrentValue
[
3
])
mCurrentValue
[
i
][
3
]
!=
attribs
[
i
].
mCurrentValue
[
3
])
{
{
unsigned
int
requiredSpace
=
sizeof
(
float
)
*
4
;
unsigned
int
requiredSpace
=
sizeof
(
float
)
*
4
;
buffer
->
reserveRawDataSpace
(
requiredSpace
);
if
(
!
buffer
->
reserveRawDataSpace
(
requiredSpace
))
{
return
GL_OUT_OF_MEMORY
;
}
int
streamOffset
=
buffer
->
storeRawData
(
attribs
[
i
].
mCurrentValue
,
requiredSpace
);
int
streamOffset
=
buffer
->
storeRawData
(
attribs
[
i
].
mCurrentValue
,
requiredSpace
);
if
(
streamOffset
==
-
1
)
if
(
streamOffset
==
-
1
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment