Skip to content

Commit 2823e93

Browse files
committed
Fixed bug #78442 ('Illegal component' on exif_read_data since PHP7)
1 parent a270eb1 commit 2823e93

File tree

5 files changed

+54
-23
lines changed

5 files changed

+54
-23
lines changed

ext/exif/exif.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,28 +1002,24 @@ static tag_info_array tag_table_VND_PANASONIC = {
10021002
{ 0x0001, "Quality"},
10031003
{ 0x0002, "FirmwareVersion"},
10041004
{ 0x0003, "WhiteBalance"},
1005-
{ 0x0004, "0x0004"},
10061005
{ 0x0007, "FocusMode"},
10071006
{ 0x000f, "AFMode"},
10081007
{ 0x001a, "ImageStabilization"},
10091008
{ 0x001c, "Macro"},
10101009
{ 0x001f, "ShootingMode"},
10111010
{ 0x0020, "Audio"},
10121011
{ 0x0021, "DataDump"},
1013-
{ 0x0022, "0x0022"},
10141012
{ 0x0023, "WhiteBalanceBias"},
10151013
{ 0x0024, "FlashBias"},
10161014
{ 0x0025, "InternalSerialNumber"},
10171015
{ 0x0026, "ExifVersion"},
1018-
{ 0x0027, "0x0027"},
10191016
{ 0x0028, "ColorEffect"},
10201017
{ 0x0029, "TimeSincePowerOn"},
10211018
{ 0x002a, "BurstMode"},
10221019
{ 0x002b, "SequenceNumber"},
10231020
{ 0x002c, "Contrast"},
10241021
{ 0x002d, "NoiseReduction"},
10251022
{ 0x002e, "SelfTimer"},
1026-
{ 0x002f, "0x002f"},
10271023
{ 0x0030, "Rotation"},
10281024
{ 0x0031, "AFAssistLamp"},
10291025
{ 0x0032, "ColorMode"},
@@ -1090,7 +1086,6 @@ static tag_info_array tag_table_VND_PANASONIC = {
10901086
{ 0x00a3, "ClearRetouchValue"},
10911087
{ 0x00ab, "TouchAE"},
10921088
{ 0x0e00, "PrintIM"},
1093-
{ 0x4449, "0x4449"},
10941089
{ 0x8000, "MakerNoteVersion"},
10951090
{ 0x8001, "SceneMode"},
10961091
{ 0x8004, "WBRedLevel"},
@@ -1125,22 +1120,20 @@ static tag_info_array tag_table_VND_SONY = {
11251120
{ 0x0112, "WhiteBalanceFineTune"},
11261121
{ 0x0114, "CameraSettings"},
11271122
{ 0x0115, "WhiteBalance"},
1128-
{ 0x0116, "0x0116"},
1123+
{ 0x0116, "ExtraInfo"},
11291124
{ 0x0e00, "PrintIM"},
11301125
{ 0x1000, "MultiBurstMode"},
11311126
{ 0x1001, "MultiBurstImageWidth"},
11321127
{ 0x1002, "MultiBurstImageHeight"},
11331128
{ 0x1003, "Panorama"},
1134-
{ 0x2000, "0x2000"},
11351129
{ 0x2001, "PreviewImage"},
1136-
{ 0x2002, "0x2002"},
1137-
{ 0x2003, "0x2003"},
1130+
{ 0x2002, "Rating"},
11381131
{ 0x2004, "Contrast"},
11391132
{ 0x2005, "Saturation"},
1140-
{ 0x2006, "0x2006"},
1141-
{ 0x2007, "0x2007"},
1142-
{ 0x2008, "0x2008"},
1143-
{ 0x2009, "0x2009"},
1133+
{ 0x2006, "Sharpness"},
1134+
{ 0x2007, "Brightness"},
1135+
{ 0x2008, "LongExposureNoiseReduction"},
1136+
{ 0x2009, "HighISONoiseReduction"},
11441137
{ 0x200a, "AutoHDR"},
11451138
{ 0x3000, "ShotInfo"},
11461139
{ 0xb000, "FileFormat"},
@@ -1167,8 +1160,9 @@ static tag_info_array tag_table_VND_SONY = {
11671160
{ 0xb049, "ReleaseMode"},
11681161
{ 0xb04a, "SequenceNumber"},
11691162
{ 0xb04b, "AntiBlur"},
1170-
{ 0xb04e, "LongExposureNoiseReduction"},
1163+
{ 0xb04e, "FocusMode"},
11711164
{ 0xb04f, "DynamicRangeOptimizer"},
1165+
{ 0xb050, "HighISONoiseReduction2"},
11721166
{ 0xb052, "IntelligentAuto"},
11731167
{ 0xb054, "WhiteBalance2"},
11741168
TAG_TABLE_END
@@ -1273,7 +1267,6 @@ static tag_info_array tag_table_VND_MINOLTA = {
12731267
{ 0x0100, "SceneMode"},
12741268
{ 0x0101, "ColorMode"},
12751269
{ 0x0102, "Quality"},
1276-
{ 0x0103, "0x0103"},
12771270
{ 0x0104, "FlashExposureComp"},
12781271
{ 0x0105, "Teleconverter"},
12791272
{ 0x0107, "ImageStabilization"},
@@ -1369,6 +1362,7 @@ static const maker_note_type maker_note_array[] = {
13691362
{ tag_table_VND_PANASONIC, "Panasonic", NULL, "Panasonic\x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
13701363
{ tag_table_VND_DJI, "DJI", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
13711364
{ tag_table_VND_SONY, "SONY", NULL, "SONY DSC \x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
1365+
{ tag_table_VND_SONY, "SONY", NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
13721366
{ tag_table_VND_PENTAX, "PENTAX", NULL, "AOC\x00", 6, 6, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
13731367
{ tag_table_VND_MINOLTA, "Minolta, KONICA MINOLTA", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
13741368
{ tag_table_VND_SIGMA, "SIGMA, FOVEON", NULL, "SIGMA\x00\x00\x00", 10, 10, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
@@ -3295,7 +3289,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
32953289
/*return TRUE;*/
32963290
}
32973291

3298-
if (components <= 0) {
3292+
if (components < 0) {
32993293
exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "Process tag(x%04X=%s): Illegal components(%d)", tag, exif_get_tagname(tag, tagname, -12, tag_table), components);
33003294
return FALSE;
33013295
}

ext/exif/tests/bug68547.phpt

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,48 @@ Bug #68547 (Exif Header component value check error)
44
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
55
--FILE--
66
<?php
7-
exif_read_data(__DIR__ . DIRECTORY_SEPARATOR . 'bug68547.jpg');
7+
var_dump(exif_read_data(__DIR__ . DIRECTORY_SEPARATOR . 'bug68547.jpg'));
88
?>
99
===DONE===
1010
--EXPECTF--
11-
Warning: exif_read_data(bug68547.jpg): Process tag(x9C9E=Keywords ): Illegal components(%d) in %sbug68547.php on line %d
11+
array(12) {
12+
["FileName"]=>
13+
string(12) "bug68547.jpg"
14+
["FileDateTime"]=>
15+
int(%d)
16+
["FileSize"]=>
17+
int(713)
18+
["FileType"]=>
19+
int(2)
20+
["MimeType"]=>
21+
string(10) "image/jpeg"
22+
["SectionsFound"]=>
23+
string(20) "ANY_TAG, IFD0, WINXP"
24+
["COMPUTED"]=>
25+
array(5) {
26+
["html"]=>
27+
string(20) "width="1" height="1""
28+
["Height"]=>
29+
int(1)
30+
["Width"]=>
31+
int(1)
32+
["IsColor"]=>
33+
int(1)
34+
["ByteOrderMotorola"]=>
35+
int(0)
36+
}
37+
["Subject"]=>
38+
string(10) "Subjec??.."
39+
["Keywords"]=>
40+
string(0) ""
41+
["Author"]=>
42+
string(9) "Rui Carmo"
43+
["Comments"]=>
44+
string(29) "Comments
45+
Line2
46+
Line3
47+
Line4"
48+
["Title"]=>
49+
string(8) "Title..."
50+
}
1251
===DONE===

ext/exif/tests/bug68799.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,14 @@ print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
3939

4040
?>
4141
--EXPECTF--
42-
Warning: exif_read_data(bug68799.jpg): Process tag(x9C9D=Author ): Illegal components(%d) in %s on line %d
4342
Array
4443
(
4544
[FileName] => bug68799.jpg
4645
[FileDateTime] => %d
4746
[FileSize] => 735
4847
[FileType] => 2
4948
[MimeType] => image/jpeg
50-
[SectionsFound] => ANY_TAG, IFD0
49+
[SectionsFound] => ANY_TAG, IFD0, WINXP
5150
[COMPUTED] => Array
5251
(
5352
[html] => width="1" height="1"
@@ -60,4 +59,5 @@ Array
6059
[XResolution] => 96/1
6160
[YResolution] => 96/1
6261
[ResolutionUnit] => 2
62+
[Author] =>
6363
)

ext/exif/tests/bug72094.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal
4747

4848
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
4949

50-
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal components(%d) in %s%ebug72094.php on line %d
50+
Warning: exif_read_data(bug72094_3.jpg): Illegal IFD size in %s%ebug72094.php on line %d
5151

5252
Warning: exif_read_data(bug72094_3.jpg): File structure corrupted in %s%ebug72094.php on line %d
5353

ext/exif/tests/bug73737.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ Bug #73737 (Crash when parsing a tag format)
88
var_dump($exif);
99
?>
1010
--EXPECTF--
11-
Warning: exif_thumbnail(bug73737.tiff): Process tag(x0100=ImageWidth ): Illegal components(0) in %s on line %d
12-
1311
Warning: exif_thumbnail(bug73737.tiff): Error in TIFF: filesize(x0030) less than start of IFD dir(x10102) in %s line %d
1412
bool(false)

0 commit comments

Comments
 (0)