st/mesa: use signed temporary variable to store _ColorDrawBufferIndexes
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 15 Jan 2014 11:39:24 +0000 (11:39 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 15 Jan 2014 14:33:28 +0000 (14:33 +0000)
The temporary variable used to store _ColorDrawBufferIndexes must be
signed (GLint), otherwise the following conditional will be incorrectly
evaluated. Leading to crashes in the driver/mesa or accessing/writing
to arbitrary memory location. The bug dates back to 2009.

Cc: 10.0 9.2 9.1 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/mesa/state_tracker/st_cb_clear.c

index 87dccee1f4995f1c7abc0672b406e4ad67cfd802..79124b3daa4845487425f7953f0ea4636194cad9 100644 (file)
@@ -444,7 +444,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
 
    if (mask & BUFFER_BITS_COLOR) {
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
-         GLuint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+         GLint b = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
 
          if (b >= 0 && mask & (1 << b)) {
             struct gl_renderbuffer *rb