Medium firefox Logic Error 🔧 Commit mapped

Overview

Medium
Severity
CVSS
No
Exploited ITW
Fixed
Fix Status
Impactmoderate
DescriptionIncorrect boundary conditions in the Graphics component
ComponentGraphics
Bug ClassLogic Error
Tracker2015268
Fix commit4fd494b83df8 (firefox) +17/-0
CISA KEVNot listed
CreditedSajeeb Lohani
Disclosed2026-03-24

Files Changed

  • gfx/layers/ImageDataSerializer.cpp
  • gfx/layers/composite/TextureHost.cpp
  • gfx/webrender_bindings/RenderBufferTextureHost.cpp
diff --git a/gfx/layers/ImageDataSerializer.cpp b/gfx/layers/ImageDataSerializer.cpp
index 12918e92c28..182c64fd49e 100644
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -338,6 +338,8 @@ void ConvertAndScaleFromYCbCrDescriptor(uint8_t* aBuffer,
                                         unsigned char* aDestBuffer,
                                         int32_t aStride) {
   MOZ_ASSERT(aBuffer);
+  MOZ_ASSERT(gfx::IntRect(gfx::IntPoint(), aDescriptor.ySize())
+                 .Contains(aDescriptor.display()));
 
   layers::PlanarYCbCrData ycbcrData;
   ycbcrData.mYChannel = GetYChannel(aBuffer, aDescriptor);
diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp
index f865f8e6683..a7ba5574920 100644
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -277,6 +277,17 @@ already_AddRefed<TextureHost> CreateBackendIndependentTextureHost(
           switch (desc.type()) {
             case BufferDescriptor::TYCbCrDescriptor: {
               const YCbCrDescriptor& ycbcr = desc.get_YCbCrDescriptor();
+              if (!gfx::IntRect(gfx::IntPoint(), ycbcr.ySize())
+                       .Contains(ycbcr.display())) {
+                NS_ERROR("YCbCr display rect exceeds Y plane dimensions!");
+                return nullptr;
+              }
+              auto croppedCbCr = ImageDataSerializer::GetCroppedCbCrSize(ycbcr);
+              if (croppedCbCr.width > ycbcr.cbCrSize().width ||
+                  croppedCbCr.height > ycbcr.cbCrSize().height) {
+                NS_ERROR("YCbCr display rect exceeds CbCr plane dimensions!");
+                return nullptr;
+              }
               reqSize = ImageDataSerializer::ComputeYCbCrBufferSize(
                   ycbcr.ySize(), ycbcr.yStride(), ycbcr.cbCrSize(),
                   ycbcr.cbCrStride(), ycbcr.yOffset(), ycbcr.cbOffset(),
@@ -460,6 +471,8 @@ BufferTextureHost::BufferTextureHost(const BufferDescriptor& aDesc,
   switch (mDescriptor.type()) {
     case BufferDescriptor::TYCbCrDescriptor: {
       const YCbCrDescriptor& ycbcr = mDescriptor.get_YCbCrDescriptor();
+      MOZ_ASSERT(gfx::IntRect(gfx::IntPoint(), ycbcr.ySize())
+                     .Contains(ycbcr.display()));
       mSize = ycbcr.display().Size();
       mFormat = gfx::SurfaceFormat::YUV420;
       break;
diff --git a/gfx/webrender_bindings/RenderBufferTextureHost.cpp b/gfx/webrender_bindings/RenderBufferTextureHost.cpp
index 4db8d0134f0..6d6c6b4765b 100644
--- a/gfx/webrender_bindings/RenderBufferTextureHost.cpp
+++ b/gfx/webrender_bindings/RenderBufferTextureHost.cpp
@@ -26,6 +26,8 @@ RenderBufferTextureHost::RenderBufferTextureHost(
   switch (mDescriptor.type()) {
     case layers::BufferDescriptor::TYCbCrDescriptor: {
       const layers::YCbCrDescriptor& ycbcr = mDescriptor.get_YCbCrDescriptor();
+      MOZ_ASSERT(gfx::IntRect(gfx::IntPoint(), ycbcr.ySize())
+                     .Contains(ycbcr.display()));
       mSize = ycbcr.display().Size();
       mFormat = gfx::SurfaceFormat::YUV420;
       break;
Loading diff…