Skip to content

Commit 41f66e2

Browse files
committed
Fixed bug #79282
1 parent 63f6608 commit 41f66e2

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
@@ -3692,6 +3692,11 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
36923692
{
36933693
unsigned exif_value_2a, offset_of_ifd;
36943694

3695+
if (length < 2) {
3696+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
3697+
return;
3698+
}
3699+
36953700
/* set the thumbnail stuff to nothing so we can test to see if they get set up */
36963701
if (memcmp(CharBuf, "II", 2) == 0) {
36973702
ImageInfo->motorola_intel = 0;
@@ -3844,7 +3849,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
38443849
return FALSE;
38453850
}
38463851

3847-
sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
3852+
sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
38483853
Data = ImageInfo->file.list[sn].data;
38493854

38503855
/* 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)