File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -715,6 +715,9 @@ static avifBool avifJPEGExtractGainMapImageFromMpf(FILE * f,
715715 for (int mpTagIdx = 0 ; mpTagIdx < mpTagCount ; ++ mpTagIdx ) {
716716 uint16_t tagId ;
717717 AVIF_CHECK (avifJPEGReadU16 (segmentData , & tagId , & offset , isBigEndian ));
718+ if (UINT32_MAX - offset < 2 + 4 ) {
719+ return AVIF_FALSE ;
720+ }
718721 offset += 2 ; // Skip data format.
719722 offset += 4 ; // Skip num components.
720723 uint8_t valueBytes [4 ];
@@ -749,12 +752,18 @@ static avifBool avifJPEGExtractGainMapImageFromMpf(FILE * f,
749752 AVIF_CHECK (avifJPEGFindMpfSegmentOffset (f , & mpfSegmentOffset ));
750753
751754 for (uint32_t imageIdx = 0 ; imageIdx < numImages ; ++ imageIdx ) {
755+ if (UINT32_MAX - offset < 4 ) {
756+ return AVIF_FALSE ;
757+ }
752758 offset += 4 ; // Skip "Individual Image Attribute"
753759 uint32_t imageSize ;
754760 AVIF_CHECK (avifJPEGReadU32 (segmentData , & imageSize , & offset , isBigEndian ));
755761 uint32_t imageDataOffset ;
756762 AVIF_CHECK (avifJPEGReadU32 (segmentData , & imageDataOffset , & offset , isBigEndian ));
757763
764+ if (UINT32_MAX - offset < 4 ) {
765+ return AVIF_FALSE ;
766+ }
758767 offset += 4 ; // Skip "Dependent image Entry Number" (2 + 2 bytes)
759768 if (imageDataOffset == 0 ) {
760769 // 0 is a special value which indicates the first image.
You can’t perform that action at this time.
0 commit comments