~ubuntu-branches/ubuntu/precise/mesa/precise-security

« back to all changes in this revision

Viewing changes to src/mesa/drivers/common/meta.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers, Steve Beattie
  • Date: 2012-10-19 09:04:04 UTC
  • mfrom: (163.1.4 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20121019090404-5zbjpsp6knv7zl3b
Tags: 8.0.4-0ubuntu0.2
[ Steve Beattie ]
* SECURITY UPDATE: samplers array overflow (LP: #1046933)
  - debian/patches/50-CVE-2012-2864.patch: ensure that more than
    MAX_SAMPLERS are not used
  - CVE-2012-2864

Show diffs side-by-side

added added

removed removed

Lines of Context:
315
315
   struct drawtex_state DrawTex;  /**< For _mesa_meta_DrawTex() */
316
316
};
317
317
 
 
318
static void meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit);
 
319
static void cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex);
 
320
static void meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear);
 
321
 
318
322
static GLuint
319
323
compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source)
320
324
{
331
335
      return shader;
332
336
 
333
337
   _mesa_GetShaderiv(shader, GL_INFO_LOG_LENGTH, &size);
334
 
   if (size == 0)
 
338
   if (size == 0) {
 
339
      _mesa_DeleteObjectARB(shader);
335
340
      return 0;
 
341
   }
336
342
 
337
343
   info = malloc(size);
338
 
   if (!info)
 
344
   if (!info) {
 
345
      _mesa_DeleteObjectARB(shader);
339
346
      return 0;
 
347
   }
340
348
 
341
349
   _mesa_GetProgramInfoLog(shader, size, NULL, info);
342
350
   _mesa_problem(ctx,
345
353
                 info, source);
346
354
 
347
355
   free(info);
 
356
   _mesa_DeleteObjectARB(shader);
348
357
 
349
358
   return 0;
350
359
}
397
406
void
398
407
_mesa_meta_free(struct gl_context *ctx)
399
408
{
400
 
   /* Note: Any textures, VBOs, etc, that we allocate should get
401
 
    * freed by the normal context destruction code.  But this would be
402
 
    * the place to free other meta data someday.
403
 
    */
 
409
   GET_CURRENT_CONTEXT(old_context);
 
410
   _mesa_make_current(ctx, NULL, NULL);
 
411
   meta_glsl_blit_cleanup(ctx, &ctx->Meta->Blit);
 
412
   meta_glsl_clear_cleanup(ctx, &ctx->Meta->Clear);
 
413
   cleanup_temp_texture(ctx, &ctx->Meta->TempTex);
 
414
   if (old_context)
 
415
      _mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer);
 
416
   else
 
417
      _mesa_make_current(NULL, NULL, NULL);
404
418
   free(ctx->Meta);
405
419
   ctx->Meta = NULL;
406
420
}
1056
1070
   _mesa_GenTextures(1, &tex->TexObj);
1057
1071
}
1058
1072
 
 
1073
static void
 
1074
cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex)
 
1075
{
 
1076
   if (!tex->TexObj)
 
1077
     return;
 
1078
   _mesa_DeleteTextures(1, &tex->TexObj);
 
1079
   tex->TexObj = 0;
 
1080
}
 
1081
 
1059
1082
 
1060
1083
/**
1061
1084
 * Return pointer to temp_texture info for non-bitmap ops.
1592
1615
   }
1593
1616
}
1594
1617
 
 
1618
static void
 
1619
meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit)
 
1620
{
 
1621
   if (blit->ArrayObj) {
 
1622
      _mesa_DeleteVertexArraysAPPLE(1, &blit->ArrayObj);
 
1623
      blit->ArrayObj = 0;
 
1624
      _mesa_DeleteBuffersARB(1, &blit->VBO);
 
1625
      blit->VBO = 0;
 
1626
   }
 
1627
   if (blit->DepthFP) {
 
1628
      _mesa_DeletePrograms(1, &blit->DepthFP);
 
1629
      blit->DepthFP = 0;
 
1630
   }
 
1631
}
 
1632
 
1595
1633
 
1596
1634
/**
1597
1635
 * Meta implementation of ctx->Driver.Clear() in terms of polygon rendering.
1774
1812
 
1775
1813
   clear->ShaderProg = _mesa_CreateProgramObjectARB();
1776
1814
   _mesa_AttachShader(clear->ShaderProg, fs);
 
1815
   _mesa_DeleteObjectARB(fs);
1777
1816
   _mesa_AttachShader(clear->ShaderProg, vs);
 
1817
   _mesa_DeleteObjectARB(vs);
1778
1818
   _mesa_BindAttribLocationARB(clear->ShaderProg, 0, "position");
1779
1819
   _mesa_LinkProgramARB(clear->ShaderProg);
1780
1820
 
1787
1827
 
1788
1828
      clear->IntegerShaderProg = _mesa_CreateProgramObjectARB();
1789
1829
      _mesa_AttachShader(clear->IntegerShaderProg, fs);
 
1830
      _mesa_DeleteObjectARB(fs);
1790
1831
      _mesa_AttachShader(clear->IntegerShaderProg, vs);
 
1832
      _mesa_DeleteObjectARB(vs);
1791
1833
      _mesa_BindAttribLocationARB(clear->IntegerShaderProg, 0, "position");
1792
1834
 
1793
1835
      /* Note that user-defined out attributes get automatically assigned
1802
1844
   }
1803
1845
}
1804
1846
 
 
1847
static void
 
1848
meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear)
 
1849
{
 
1850
   if (clear->ArrayObj == 0)
 
1851
      return;
 
1852
   _mesa_DeleteVertexArraysAPPLE(1, &clear->ArrayObj);
 
1853
   clear->ArrayObj = 0;
 
1854
   _mesa_DeleteBuffersARB(1, &clear->VBO);
 
1855
   clear->VBO = 0;
 
1856
   _mesa_DeleteObjectARB(clear->ShaderProg);
 
1857
   clear->ShaderProg = 0;
 
1858
 
 
1859
   if (clear->IntegerShaderProg) {
 
1860
      _mesa_DeleteObjectARB(clear->IntegerShaderProg);
 
1861
      clear->IntegerShaderProg = 0;
 
1862
   }
 
1863
}
 
1864
 
1805
1865
/**
1806
1866
 * Meta implementation of ctx->Driver.Clear() in terms of polygon rendering.
1807
1867
 */
3256
3316
   };
3257
3317
   struct vertex verts[4];
3258
3318
   GLuint fboDrawSave, fboReadSave;
 
3319
   GLuint rbSave;
3259
3320
 
3260
3321
   if (slice > 0) {
3261
3322
      assert(target == GL_TEXTURE_3D ||
3272
3333
   /* save fbo bindings (not saved by _mesa_meta_begin()) */
3273
3334
   fboDrawSave = ctx->DrawBuffer->Name;
3274
3335
   fboReadSave = ctx->ReadBuffer->Name;
 
3336
   rbSave = ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
3275
3337
 
3276
3338
   _mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_PIXEL_STORE);
3277
3339
 
3292
3354
 
3293
3355
   /* alloc dest surface */
3294
3356
   if (width > decompress->Width || height > decompress->Height) {
 
3357
      _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, decompress->RBO);
3295
3358
      _mesa_RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA,
3296
3359
                                   width, height);
3297
3360
      decompress->Width = width;
3424
3487
      _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fboDrawSave);
3425
3488
      _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fboReadSave);
3426
3489
   }
 
3490
   _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, rbSave);
3427
3491
}
3428
3492
 
3429
3493