summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-02-09 16:18:39 +0000
committerBrian Paul <[email protected]>2005-02-09 16:18:39 +0000
commita8d5b176b5208de61667ce0d901d69485eea1957 (patch)
tree1f5e3664c105721c2f48bab15509171672d94ae7
parentfe7aa08ad982ebca9d867905eccb5315fa4ed23a (diff)
Added a test/clamp in the scale_internal_*() functions to prevent reading
a row of pixels beyond the input buffer's bounds. FDO/Mesa bug #2510.
-rw-r--r--src/glu/sgi/libutil/mipmap.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/glu/sgi/libutil/mipmap.c b/src/glu/sgi/libutil/mipmap.c
index 0122a2aff69..b81b9bc39d3 100644
--- a/src/glu/sgi/libutil/mipmap.c
+++ b/src/glu/sgi/libutil/mipmap.c
@@ -1409,6 +1409,9 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -1450,7 +1453,7 @@ static void scale_internal_ubyte(GLint components, GLint widthin,
totals[k] += (GLubyte)(*(temp_index)) * percent;
}
- /* calculate the value for pixels in the last row */
+ /* calculate the value for pixels in the last row */
y_percent = highy_float;
percent = y_percent * (1-lowx_float);
temp = (const char *)datain + xindex + highy_int * ysize;
@@ -1623,6 +1626,9 @@ static void scale_internal_byte(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -1838,6 +1844,9 @@ static void scale_internal_ushort(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -2117,6 +2126,9 @@ static void scale_internal_short(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -2406,6 +2418,9 @@ static void scale_internal_uint(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -2692,6 +2707,9 @@ static void scale_internal_int(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;
@@ -2985,6 +3003,9 @@ static void scale_internal_float(GLint components, GLint widthin,
highy_float = convy_float;
for (i = 0; i < heightout; i++) {
+ /* Clamp here to be sure we don't read beyond input buffer. */
+ if (highy_int >= heightin)
+ highy_int = heightin - 1;
lowx_int = 0;
lowx_float = 0;
highx_int = convx_int;