Skip to content

Commit 8ac6fee

Browse files
committed
Fix bug #77563 - Uninitialized read in exif_process_IFD_in_MAKERNOTE
Also fix for bug #77659
1 parent 5f0e62a commit 8ac6fee

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

ext/exif/exif.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2741,7 +2741,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
27412741
break;
27422742
}
27432743

2744-
if (maker_note->offset >= value_len) {
2744+
if (value_len < 2 || maker_note->offset >= value_len - 1) {
27452745
/* Do not go past the value end */
27462746
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X offset 0x%04X", value_len, maker_note->offset);
27472747
return FALSE;
@@ -2794,6 +2794,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
27942794
break;
27952795
default:
27962796
case MN_OFFSET_NORMAL:
2797+
data_len = value_len;
27972798
break;
27982799
}
27992800

ext/exif/tests/bug77563.jpg

63 Bytes
Loading

ext/exif/tests/bug77563.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug 77563 (Uninitialized read in exif_process_IFD_in_MAKERNOTE)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
$s = exif_thumbnail(__DIR__."/bug77563.jpg");
8+
?>
9+
DONE
10+
--EXPECTF--
11+
Warning: exif_thumbnail(bug77563.jpg): Illegal IFD offset in %s/bug77563.php on line %d
12+
13+
Warning: exif_thumbnail(bug77563.jpg): File structure corrupted in %s/bug77563.php on line %d
14+
15+
Warning: exif_thumbnail(bug77563.jpg): Invalid JPEG file in %s/bug77563.php on line %d
16+
DONE

0 commit comments

Comments
 (0)