Skip to content

Commit b9d3219

Browse files
committed
Fixed bug #79282
1 parent aa88f33 commit b9d3219

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

ext/exif/exif.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3677,6 +3677,11 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
36773677
{
36783678
unsigned exif_value_2a, offset_of_ifd;
36793679

3680+
if (length < 2) {
3681+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
3682+
return;
3683+
}
3684+
36803685
/* set the thumbnail stuff to nothing so we can test to see if they get set up */
36813686
if (memcmp(CharBuf, "II", 2) == 0) {
36823687
ImageInfo->motorola_intel = 0;
@@ -3829,7 +3834,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
38293834
return FALSE;
38303835
}
38313836

3832-
sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
3837+
sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
38333838
Data = ImageInfo->file.list[sn].data;
38343839

38353840
/* Store first two pre-read bytes. */

ext/exif/tests/bug79282.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #79282: Use-of-uninitialized-value in exif
3+
--FILE--
4+
<?php
5+
6+
var_dump(exif_read_data('data://image/jpeg;base64,/9jhAAlFeGlmAAAg'));
7+
8+
?>
9+
--EXPECTF--
10+
Warning: exif_read_data(): Invalid TIFF alignment marker in %s on line %d
11+
12+
Warning: exif_read_data(): File structure corrupted in %s on line %d
13+
14+
Warning: exif_read_data(): Invalid JPEG file in %s on line %d
15+
bool(false)

0 commit comments

Comments
 (0)