[Mesa-dev] [PATCH 4/8] mesa: standardize some bounds-checking error messages
nobled
nobled at dreamwidth.org
Tue Apr 19 19:30:30 PDT 2011
---
src/mesa/main/pixel.c | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 6e4ed99..62dd13e 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -145,8 +145,9 @@ store_pixelmap(struct gl_context *ctx, GLenum map,
GLsizei mapsize,
* Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap().
*/
static GLboolean
-validate_pbo_access(struct gl_context *ctx, struct gl_pixelstore_attrib *pack,
- GLsizei mapsize, GLenum format, GLenum type,
+validate_pbo_access(struct gl_context *ctx,
+ struct gl_pixelstore_attrib *pack, GLsizei mapsize,
+ GLenum format, GLenum type, GLsizei clientMemSize,
const GLvoid *ptr)
{
GLboolean ok;
@@ -157,7 +158,7 @@ validate_pbo_access(struct gl_context *ctx, struct
gl_pixelstore_attrib *pack,
pack->BufferObj);
ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
- format, type, INT_MAX, ptr);
+ format, type, clientMemSize, ptr);
/* restore */
_mesa_reference_buffer_object(ctx,
@@ -165,8 +166,14 @@ validate_pbo_access(struct gl_context *ctx,
struct gl_pixelstore_attrib *pack,
ctx->Shared->NullBufferObj);
if (!ok) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glPixelMap(invalid PBO access)");
+ if (_mesa_is_bufferobj(pack->BufferObj)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "gl[Get]PixelMap*v(out of bounds PBO access)");
+ } else {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetnPixelMap*vARB(out of bounds access:"
+ " bufSize (%d) is too small)", clientMemSize);
+ }
}
return ok;
}
@@ -194,8 +201,8 @@ _mesa_PixelMapfv( GLenum map, GLsizei mapsize,
const GLfloat *values )
FLUSH_VERTICES(ctx, _NEW_PIXEL);
- if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize,
- GL_INTENSITY, GL_FLOAT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
+ GL_FLOAT, INT_MAX, values)) {
return;
}
@@ -236,8 +243,8 @@ _mesa_PixelMapuiv(GLenum map, GLsizei mapsize,
const GLuint *values )
FLUSH_VERTICES(ctx, _NEW_PIXEL);
- if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize,
- GL_INTENSITY, GL_UNSIGNED_INT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
+ GL_UNSIGNED_INT, INT_MAX, values)) {
return;
}
@@ -292,8 +299,8 @@ _mesa_PixelMapusv(GLenum map, GLsizei mapsize,
const GLushort *values )
FLUSH_VERTICES(ctx, _NEW_PIXEL);
- if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize,
- GL_INTENSITY, GL_UNSIGNED_SHORT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
+ GL_UNSIGNED_SHORT, INT_MAX, values)) {
return;
}
@@ -343,8 +350,8 @@ _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
mapsize = pm->Size;
- if (!validate_pbo_access(ctx, &ctx->Pack, mapsize,
- GL_INTENSITY, GL_FLOAT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
+ GL_FLOAT, INT_MAX, values)) {
return;
}
@@ -387,8 +394,8 @@ _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
}
mapsize = pm->Size;
- if (!validate_pbo_access(ctx, &ctx->Pack, mapsize,
- GL_INTENSITY, GL_UNSIGNED_INT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
+ GL_UNSIGNED_INT, INT_MAX, values)) {
return;
}
@@ -431,8 +438,8 @@ _mesa_GetPixelMapusv( GLenum map, GLushort *values )
}
mapsize = pm->Size;
- if (!validate_pbo_access(ctx, &ctx->Pack, mapsize,
- GL_INTENSITY, GL_UNSIGNED_SHORT, values)) {
+ if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
+ GL_UNSIGNED_SHORT, INT_MAX, values)) {
return;
}
--
1.7.0.4
More information about the mesa-dev
mailing list