Skip to content

Commit

Permalink
exif: protected against large offset values
Browse files Browse the repository at this point in the history
  • Loading branch information
bradh committed Dec 1, 2023
1 parent 5e19d8b commit ca8b64a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/encoder_png.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ bool PngEncoder::Encode(const struct heif_image_handle* handle,
if (exifsize > 4) {
uint32_t skip = (exifdata[0]<<24) | (exifdata[1]<<16) | (exifdata[2]<<8) | exifdata[3];
skip += 4;
if (skip < exifsize) {
uint8_t* ptr = exifdata + skip;
size_t size = exifsize - skip;

uint8_t* ptr = exifdata + skip;
size_t size = exifsize - skip;
// libheif by default normalizes the image orientation, so that we have to set the EXIF Orientation to "Horizontal (normal)"
modify_exif_orientation_tag_if_it_exists(ptr, (int)size, 1);

// libheif by default normalizes the image orientation, so that we have to set the EXIF Orientation to "Horizontal (normal)"
modify_exif_orientation_tag_if_it_exists(ptr, (int)size, 1);

png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)size, ptr);
png_set_eXIf_1(png_ptr, info_ptr, (png_uint_32)size, ptr);
}
}

free(exifdata);
Expand Down

0 comments on commit ca8b64a

Please sign in to comment.