Commit eb48b753 authored by Andres Calderon Jaramillo's avatar Andres Calderon Jaramillo Committed by Chromium LUCI CQ

vaapi/JEA: Assert encoded/output size validity.

This CL changes a couple of DCHECKs to CHECKs as a follow-up to
CL:2554180. The reasoning is from the guideline in [1]:

  Use CHECK() if the consequence of a failed assertion would be a
  security vulnerability, where crashing the browser is preferable.

The CHECKs should not be triggered, but at least one of them is not
trivial to reason why from the existing validation.

[1] https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#check_dcheck_and-notreached

Bug: b:171340559
Test: None
Change-Id: I3e35b8f310f76bb74cde515e776b9ae00134df93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566722
Auto-Submit: Andres Calderon Jaramillo <andrescj@chromium.org>
Reviewed-by: default avatarWei Lee <wtlee@chromium.org>
Commit-Queue: Andres Calderon Jaramillo <andrescj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832226}
parent 09c506b2
......@@ -312,7 +312,7 @@ void VaapiJpegEncodeAccelerator::Encoder::EncodeWithDmaBufTask(
notify_error_cb_.Run(task_id, PLATFORM_FAILURE);
return;
}
DCHECK_LE(encoded_size, max_frame_size);
CHECK_LE(encoded_size, max_frame_size);
if (exif_buffer_size > 0) {
// Check the output header is 2+2+14 bytes APP0 as expected.
......@@ -340,7 +340,7 @@ void VaapiJpegEncodeAccelerator::Encoder::EncodeWithDmaBufTask(
static_cast<uint8_t>((exif_buffer_size + 2) / 256),
static_cast<uint8_t>((exif_buffer_size + 2) % 256),
};
DCHECK_GE(output_size, base::size(jpeg_soi_and_app1_header));
CHECK_GE(output_size, base::size(jpeg_soi_and_app1_header));
if (exif_buffer_size > output_size - base::size(jpeg_soi_and_app1_header)) {
VLOGF(1) << "Insufficient buffer size reserved for JPEG APP1 data";
notify_error_cb_.Run(task_id, PLATFORM_FAILURE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment