[WebRTC] Ensure valid image size.

Extremely small encoded image sizes should be considered corrupt data.
Drive-by improvement: make sure to cast the encoded image data length
to uint32_t for use with `CreateEmptyFrame`
This commit is contained in:
Moonchild 2026-02-25 20:01:52 +01:00 committed by OwnedByWuigi
commit e41b82bd39

View file

@ -820,7 +820,9 @@ WebrtcGmpVideoDecoder::Decode_g(const webrtc::EncodedImage& aInputImage,
}
MOZ_ASSERT(mHost);
if (!aInputImage._length) {
uint32_t dataSize=static_cast<uint32_t>(aInputImage._length);
if (dataSize < 4) {
LOGD(("GMP Decode: bad input size (%zu)!", aInputImage._length));
return WEBRTC_VIDEO_CODEC_ERROR;
}
@ -831,7 +833,7 @@ WebrtcGmpVideoDecoder::Decode_g(const webrtc::EncodedImage& aInputImage,
}
GMPUniquePtr<GMPVideoEncodedFrame> frame(static_cast<GMPVideoEncodedFrame*>(ftmp));
err = frame->CreateEmptyFrame(aInputImage._length);
err = frame->CreateEmptyFrame(dataSize);
if (err != GMPNoErr) {
return WEBRTC_VIDEO_CODEC_ERROR;
}
@ -863,7 +865,7 @@ WebrtcGmpVideoDecoder::Decode_g(const webrtc::EncodedImage& aInputImage,
nsTArray<uint8_t> codecSpecificInfo;
codecSpecificInfo.AppendElements((uint8_t*)&info, sizeof(GMPCodecSpecificInfo));
LOGD(("GMP Decode: %llu, len %d", frame->TimeStamp(), aInputImage._length));
LOGD(("GMP Decode: %llu, len %d", frame->TimeStamp(), dataSize));
nsresult rv = mGMP->Decode(Move(frame),
aMissingFrames,
codecSpecificInfo,