Skip to content

Commit f3aefc6

Browse files
committed
Fix bug #77753 - Heap-buffer-overflow in php_ifd_get32s
1 parent 0ecac37 commit f3aefc6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

ext/exif/exif.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,10 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu
28022802
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 2 + 0x%04X*12 = 0x%04X > 0x%04X", NumDirEntries, 2+NumDirEntries*12, value_len);
28032803
return FALSE;
28042804
}
2805+
if ((dir_start - value_ptr) > value_len - (2+NumDirEntries*12)) {
2806+
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Illegal IFD size: 0x%04X > 0x%04X", (dir_start - value_ptr) + (2+NumDirEntries*12), value_len);
2807+
return FALSE;
2808+
}
28052809

28062810
for (de=0;de<NumDirEntries;de++) {
28072811
if (!exif_process_IFD_TAG(ImageInfo, dir_start + 2 + 12 * de,

ext/exif/tests/bug77753.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #77753 (Heap-buffer-overflow in php_ifd_get32s)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
var_dump(exif_read_data(__DIR__."/bug77753.tiff"));
8+
?>
9+
DONE
10+
--EXPECTF--
11+
%A
12+
Warning: exif_read_data(bug77753.tiff): Illegal IFD size: 0x006A > 0x0065 in %sbug77753.php on line %d
13+
14+
Warning: exif_read_data(bug77753.tiff): Invalid TIFF file in %sbug77753.php on line %d
15+
bool(false)
16+
DONE

ext/exif/tests/bug77753.tiff

873 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)