Fixed bug #78442 ('Illegal component' on exif_read_data since PHP7)

This commit is contained in:
Kalle Sommer Nielsen 2019-09-12 06:21:39 +03:00
parent a270eb1911
commit 2823e938d4
5 changed files with 54 additions and 23 deletions

View File

@ -1002,7 +1002,6 @@ static tag_info_array tag_table_VND_PANASONIC = {
{ 0x0001, "Quality"},
{ 0x0002, "FirmwareVersion"},
{ 0x0003, "WhiteBalance"},
{ 0x0004, "0x0004"},
{ 0x0007, "FocusMode"},
{ 0x000f, "AFMode"},
{ 0x001a, "ImageStabilization"},
@ -1010,12 +1009,10 @@ static tag_info_array tag_table_VND_PANASONIC = {
{ 0x001f, "ShootingMode"},
{ 0x0020, "Audio"},
{ 0x0021, "DataDump"},
{ 0x0022, "0x0022"},
{ 0x0023, "WhiteBalanceBias"},
{ 0x0024, "FlashBias"},
{ 0x0025, "InternalSerialNumber"},
{ 0x0026, "ExifVersion"},
{ 0x0027, "0x0027"},
{ 0x0028, "ColorEffect"},
{ 0x0029, "TimeSincePowerOn"},
{ 0x002a, "BurstMode"},
@ -1023,7 +1020,6 @@ static tag_info_array tag_table_VND_PANASONIC = {
{ 0x002c, "Contrast"},
{ 0x002d, "NoiseReduction"},
{ 0x002e, "SelfTimer"},
{ 0x002f, "0x002f"},
{ 0x0030, "Rotation"},
{ 0x0031, "AFAssistLamp"},
{ 0x0032, "ColorMode"},
@ -1090,7 +1086,6 @@ static tag_info_array tag_table_VND_PANASONIC = {
{ 0x00a3, "ClearRetouchValue"},
{ 0x00ab, "TouchAE"},
{ 0x0e00, "PrintIM"},
{ 0x4449, "0x4449"},
{ 0x8000, "MakerNoteVersion"},
{ 0x8001, "SceneMode"},
{ 0x8004, "WBRedLevel"},
@ -1125,22 +1120,20 @@ static tag_info_array tag_table_VND_SONY = {
{ 0x0112, "WhiteBalanceFineTune"},
{ 0x0114, "CameraSettings"},
{ 0x0115, "WhiteBalance"},
{ 0x0116, "0x0116"},
{ 0x0116, "ExtraInfo"},
{ 0x0e00, "PrintIM"},
{ 0x1000, "MultiBurstMode"},
{ 0x1001, "MultiBurstImageWidth"},
{ 0x1002, "MultiBurstImageHeight"},
{ 0x1003, "Panorama"},
{ 0x2000, "0x2000"},
{ 0x2001, "PreviewImage"},
{ 0x2002, "0x2002"},
{ 0x2003, "0x2003"},
{ 0x2002, "Rating"},
{ 0x2004, "Contrast"},
{ 0x2005, "Saturation"},
{ 0x2006, "0x2006"},
{ 0x2007, "0x2007"},
{ 0x2008, "0x2008"},
{ 0x2009, "0x2009"},
{ 0x2006, "Sharpness"},
{ 0x2007, "Brightness"},
{ 0x2008, "LongExposureNoiseReduction"},
{ 0x2009, "HighISONoiseReduction"},
{ 0x200a, "AutoHDR"},
{ 0x3000, "ShotInfo"},
{ 0xb000, "FileFormat"},
@ -1167,8 +1160,9 @@ static tag_info_array tag_table_VND_SONY = {
{ 0xb049, "ReleaseMode"},
{ 0xb04a, "SequenceNumber"},
{ 0xb04b, "AntiBlur"},
{ 0xb04e, "LongExposureNoiseReduction"},
{ 0xb04e, "FocusMode"},
{ 0xb04f, "DynamicRangeOptimizer"},
{ 0xb050, "HighISONoiseReduction2"},
{ 0xb052, "IntelligentAuto"},
{ 0xb054, "WhiteBalance2"},
TAG_TABLE_END
@ -1273,7 +1267,6 @@ static tag_info_array tag_table_VND_MINOLTA = {
{ 0x0100, "SceneMode"},
{ 0x0101, "ColorMode"},
{ 0x0102, "Quality"},
{ 0x0103, "0x0103"},
{ 0x0104, "FlashExposureComp"},
{ 0x0105, "Teleconverter"},
{ 0x0107, "ImageStabilization"},
@ -1369,6 +1362,7 @@ static const maker_note_type maker_note_array[] = {
{ tag_table_VND_PANASONIC, "Panasonic", NULL, "Panasonic\x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ tag_table_VND_DJI, "DJI", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ tag_table_VND_SONY, "SONY", NULL, "SONY DSC \x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ tag_table_VND_SONY, "SONY", NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ tag_table_VND_PENTAX, "PENTAX", NULL, "AOC\x00", 6, 6, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ tag_table_VND_MINOLTA, "Minolta, KONICA MINOLTA", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
{ 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
/*return TRUE;*/
}
if (components <= 0) {
if (components < 0) {
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);
return FALSE;
}

View File

@ -4,9 +4,48 @@ Bug #68547 (Exif Header component value check error)
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
--FILE--
<?php
exif_read_data(__DIR__ . DIRECTORY_SEPARATOR . 'bug68547.jpg');
var_dump(exif_read_data(__DIR__ . DIRECTORY_SEPARATOR . 'bug68547.jpg'));
?>
===DONE===
--EXPECTF--
Warning: exif_read_data(bug68547.jpg): Process tag(x9C9E=Keywords ): Illegal components(%d) in %sbug68547.php on line %d
array(12) {
["FileName"]=>
string(12) "bug68547.jpg"
["FileDateTime"]=>
int(%d)
["FileSize"]=>
int(713)
["FileType"]=>
int(2)
["MimeType"]=>
string(10) "image/jpeg"
["SectionsFound"]=>
string(20) "ANY_TAG, IFD0, WINXP"
["COMPUTED"]=>
array(5) {
["html"]=>
string(20) "width="1" height="1""
["Height"]=>
int(1)
["Width"]=>
int(1)
["IsColor"]=>
int(1)
["ByteOrderMotorola"]=>
int(0)
}
["Subject"]=>
string(10) "Subjec??.."
["Keywords"]=>
string(0) ""
["Author"]=>
string(9) "Rui Carmo"
["Comments"]=>
string(29) "Comments
Line2
Line3
Line4"
["Title"]=>
string(8) "Title..."
}
===DONE===

View File

@ -39,7 +39,6 @@ print_r(exif_read_data(__DIR__.'/bug68799.jpg'));
?>
--EXPECTF--
Warning: exif_read_data(bug68799.jpg): Process tag(x9C9D=Author ): Illegal components(%d) in %s on line %d
Array
(
[FileName] => bug68799.jpg
@ -47,7 +46,7 @@ Array
[FileSize] => 735
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0
[SectionsFound] => ANY_TAG, IFD0, WINXP
[COMPUTED] => Array
(
[html] => width="1" height="1"
@ -60,4 +59,5 @@ Array
[XResolution] => 96/1
[YResolution] => 96/1
[ResolutionUnit] => 2
[Author] =>
)

View File

@ -47,7 +47,7 @@ Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal format code 0x3030, suppose BYTE in %s%ebug72094.php on line %d
Warning: exif_read_data(bug72094_3.jpg): Process tag(x3030=UndefinedTa): Illegal components(%d) in %s%ebug72094.php on line %d
Warning: exif_read_data(bug72094_3.jpg): Illegal IFD size in %s%ebug72094.php on line %d
Warning: exif_read_data(bug72094_3.jpg): File structure corrupted in %s%ebug72094.php on line %d

View File

@ -8,7 +8,5 @@ Bug #73737 (Crash when parsing a tag format)
var_dump($exif);
?>
--EXPECTF--
Warning: exif_thumbnail(bug73737.tiff): Process tag(x0100=ImageWidth ): Illegal components(0) in %s on line %d
Warning: exif_thumbnail(bug73737.tiff): Error in TIFF: filesize(x0030) less than start of IFD dir(x10102) in %s line %d
bool(false)