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

exif: protect against EXIF data overflow #1070

Merged
merged 1 commit into from
Dec 18, 2023
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
5 changes: 2 additions & 3 deletions examples/encoder_jpeg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,11 @@ bool JpegEncoder::Encode(const struct heif_image_handle* handle,
static const uint8_t kExifMarker = JPEG_APP0 + 1;

uint32_t skip = (exifdata[0]<<24) | (exifdata[1]<<16) | (exifdata[2]<<8) | exifdata[3];
skip += 4;

if (skip > exifsize) {
if (skip > (exifsize - 4)) {
fprintf(stderr, "Invalid EXIF data (offset too large)\n");
return false;
}
skip += 4;

uint8_t* ptr = exifdata + skip;
size_t size = exifsize - skip;
Expand Down
Loading