Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added patch to check that overlay's offsets are valid #1227

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions libheif/pixelimage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,26 @@ Error HeifPixelImage::overlay(std::shared_ptr<HeifPixelImage>& overlay, int dx,
"Overlay image outside of left or top canvas border");
}

// verify that the destination points are within the bounds of the image's dimensions
if (out_x0 < 0 ||
out_x0 >= out_w ||
out_y0 < 0 ||
out_y0 >= out_h) {
return Error(heif_error_Invalid_input,
heif_suberror_Invalid_overlay_data,
"Overlay image has invalid offsets");
}

// verify that the source points are within the bounds of the image's dimensions
if (in_x0 < 0 ||
in_x0 >= in_w ||
in_y0 < 0 ||
in_y0 >= in_h) {
return Error(heif_error_Invalid_input,
heif_suberror_Invalid_overlay_data,
"Overlay image has invalid offsets");
}

for (int y = in_y0; y < in_h; y++) {
if (!has_alpha) {
memcpy(out_p + out_x0 + (out_y0 + y - in_y0) * out_stride,
Expand Down
Loading