Skip to content

Commit c099c71

Browse files
smalyshevcmb69
authored andcommitted
Fixed bug #79282
(cherry picked from commit 25238bd)
1 parent f930ff5 commit c099c71

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
. Fixed bug #79311 (enchant_dict_suggest() fails on big endian architecture).
2727
(cmb)
2828

29+
- EXIF:
30+
. Fixed bug #79282 (Use-of-uninitialized-value in exif). (CVE-2020-7064)
31+
(Nikita)
32+
2933
- MySQLi:
3034
. Fixed bug #64032 (mysqli reports different client_version). (cmb)
3135

ext/exif/exif.c

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

3668+
if (length < 2) {
3669+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "Missing TIFF alignment marker");
3670+
return;
3671+
}
3672+
36683673
/* set the thumbnail stuff to nothing so we can test to see if they get set up */
36693674
if (memcmp(CharBuf, "II", 2) == 0) {
36703675
ImageInfo->motorola_intel = 0;
@@ -3817,7 +3822,7 @@ static int exif_scan_JPEG_header(image_info_type *ImageInfo)
38173822
return FALSE;
38183823
}
38193824

3820-
sn = exif_file_sections_add(ImageInfo, marker, itemlen+1, NULL);
3825+
sn = exif_file_sections_add(ImageInfo, marker, itemlen, NULL);
38213826
Data = ImageInfo->file.list[sn].data;
38223827

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