]> granicus.if.org Git - php/commitdiff
Fixed Redhat bug #1362571 (PHP not returning full results for exif_read_data function)
authorKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Aug 2016 09:59:30 +0000 (11:59 +0200)
committerKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Aug 2016 09:59:30 +0000 (11:59 +0200)
There are two factors for this bug fix:
 - First of all, the maximum nesting level has been increased to 150 (previously 100), I'm not sure how much an impact this will have, but increasing this value also seems to resolve PHP bug #66443 (Corrupt EXIF header: maximum directory nesting level reached for some cameras.)
  - Second, this adds support for most common Panasonic EXIF tags, again this list is based off the Exiv2 website

Note about Panasonic's format:
From what I could find, then the offset was always 12 bytes for such, the signature always had the 'P' capitalized, and the rest lower cased, followed by 3 NULL bytes

@Remi, can you review this? I'm gonna look into Sony (which is huge btw!) and your patch next

ext/exif/exif.c
ext/exif/tests/redhat-bug1362571.jpg [new file with mode: 0644]
ext/exif/tests/redhat-bug1362571.phpt [new file with mode: 0644]

index e08509a08150594d647d95392112d9ffac18f651..82473db8118c48de7cf07f371897c507566ba5c4 100644 (file)
@@ -89,7 +89,7 @@ typedef unsigned char uchar;
 
 #define EFREE_IF(ptr)  if (ptr) efree(ptr)
 
-#define MAX_IFD_NESTING_LEVEL 100
+#define MAX_IFD_NESTING_LEVEL 150
 
 /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO(arginfo_exif_tagname, 0)
@@ -956,37 +956,143 @@ static tag_info_array tag_table_VND_OLYMPUS = {
 };
 
 static tag_info_array tag_table_VND_SAMSUNG = {
-       { 0x0001, "Version"}, 
-       { 0x0021, "PictureWizard"}, 
-       { 0x0030, "LocalLocationName"}, 
-       { 0x0031, "LocationName"}, 
-       { 0x0035, "Preview"}, 
-       { 0x0043, "CameraTemperature"}, 
-       { 0xa001, "FirmwareName"}, 
-       { 0xa003, "LensType"}, 
-       { 0xa004, "LensFirmware"}, 
-       { 0xa010, "SensorAreas"}, 
-       { 0xa011, "ColorSpace"}, 
-       { 0xa012, "SmartRange"}, 
-       { 0xa013, "ExposureBiasValue"}, 
-       { 0xa014, "ISO"}, 
-       { 0xa018, "ExposureTime"}, 
-       { 0xa019, "FNumber"}, 
-       { 0xa01a, "FocalLengthIn35mmFormat"}, 
-       { 0xa020, "EncryptionKey"}, 
-       { 0xa021, "WB_RGGBLevelsUncorrected"}, 
-       { 0xa022, "WB_RGGBLevelsAuto"}, 
-       { 0xa023, "WB_RGGBLevelsIlluminator1"}, 
-       { 0xa024, "WB_RGGBLevelsIlluminator2"}, 
-       { 0xa028, "WB_RGGBLevelsBlack"}, 
-       { 0xa030, "ColorMatrix"}, 
-       { 0xa031, "ColorMatrixSRGB"}, 
-       { 0xa032, "ColorMatrixAdobeRGB"}, 
-       { 0xa040, "ToneCurve1"}, 
-       { 0xa041, "ToneCurve2"}, 
-       { 0xa042, "ToneCurve3"}, 
-       { 0xa043, "ToneCurve4"}, 
-       TAG_TABLE_END
+  { 0x0001, "Version"}, 
+  { 0x0021, "PictureWizard"}, 
+  { 0x0030, "LocalLocationName"}, 
+  { 0x0031, "LocationName"}, 
+  { 0x0035, "Preview"}, 
+  { 0x0043, "CameraTemperature"}, 
+  { 0xa001, "FirmwareName"}, 
+  { 0xa003, "LensType"}, 
+  { 0xa004, "LensFirmware"}, 
+  { 0xa010, "SensorAreas"}, 
+  { 0xa011, "ColorSpace"}, 
+  { 0xa012, "SmartRange"}, 
+  { 0xa013, "ExposureBiasValue"}, 
+  { 0xa014, "ISO"}, 
+  { 0xa018, "ExposureTime"}, 
+  { 0xa019, "FNumber"}, 
+  { 0xa01a, "FocalLengthIn35mmFormat"}, 
+  { 0xa020, "EncryptionKey"}, 
+  { 0xa021, "WB_RGGBLevelsUncorrected"}, 
+  { 0xa022, "WB_RGGBLevelsAuto"}, 
+  { 0xa023, "WB_RGGBLevelsIlluminator1"}, 
+  { 0xa024, "WB_RGGBLevelsIlluminator2"}, 
+  { 0xa028, "WB_RGGBLevelsBlack"}, 
+  { 0xa030, "ColorMatrix"}, 
+  { 0xa031, "ColorMatrixSRGB"}, 
+  { 0xa032, "ColorMatrixAdobeRGB"}, 
+  { 0xa040, "ToneCurve1"}, 
+  { 0xa041, "ToneCurve2"}, 
+  { 0xa042, "ToneCurve3"}, 
+  { 0xa043, "ToneCurve4"}, 
+  TAG_TABLE_END
+};
+
+static tag_info_array tag_table_VND_PANASONIC = {
+  { 0x0001, "Quality"},
+  { 0x0002, "FirmwareVersion"},
+  { 0x0003, "WhiteBalance"},
+  { 0x0004, "0x0004"},
+  { 0x0007, "FocusMode"},
+  { 0x000f, "AFMode"},
+  { 0x001a, "ImageStabilization"},
+  { 0x001c, "Macro"},
+  { 0x001f, "ShootingMode"},
+  { 0x0020, "Audio"},
+  { 0x0021, "DataDump"},
+  { 0x0022, "0x0022"},
+  { 0x0023, "WhiteBalanceBias"},
+  { 0x0024, "FlashBias"},
+  { 0x0025, "InternalSerialNumber"},
+  { 0x0026, "ExifVersion"},
+  { 0x0027, "0x0027"},
+  { 0x0028, "ColorEffect"},
+  { 0x0029, "TimeSincePowerOn"},
+  { 0x002a, "BurstMode"},
+  { 0x002b, "SequenceNumber"},
+  { 0x002c, "Contrast"},
+  { 0x002d, "NoiseReduction"},
+  { 0x002e, "SelfTimer"},
+  { 0x002f, "0x002f"},
+  { 0x0030, "Rotation"},
+  { 0x0031, "AFAssistLamp"},
+  { 0x0032, "ColorMode"},
+  { 0x0033, "BabyAge1"},
+  { 0x0034, "OpticalZoomMode"},
+  { 0x0035, "ConversionLens"},
+  { 0x0036, "TravelDay"},
+  { 0x0039, "Contrast"},
+  { 0x003a, "WorldTimeLocation"},
+  { 0x003b, "TextStamp1"},
+  { 0x003c, "ProgramISO"},
+  { 0x003d, "AdvancedSceneType"},
+  { 0x003e, "TextStamp2"},
+  { 0x003f, "FacesDetected"},
+  { 0x0040, "Saturation"},
+  { 0x0041, "Sharpness"},
+  { 0x0042, "FilmMode"},
+  { 0x0044, "ColorTempKelvin"},
+  { 0x0045, "BracketSettings"},
+  { 0x0046, "WBAdjustAB"},
+  { 0x0047, "WBAdjustGM"},
+  { 0x0048, "FlashCurtain"},
+  { 0x0049, "LongShutterNoiseReduction"},
+  { 0x004b, "ImageWidth"},
+  { 0x004c, "ImageHeight"},
+  { 0x004d, "AFPointPosition"},
+  { 0x004e, "FaceDetInfo"},
+  { 0x0051, "LensType"},
+  { 0x0052, "LensSerialNumber"},
+  { 0x0053, "AccessoryType"},
+  { 0x0054, "AccessorySerialNumber"},
+  { 0x0059, "Transform1"},
+  { 0x005d, "IntelligentExposure"},
+  { 0x0060, "LensFirmwareVersion"},
+  { 0x0061, "FaceRecInfo"},
+  { 0x0062, "FlashWarning"},
+  { 0x0065, "Title"},
+  { 0x0066, "BabyName"},
+  { 0x0067, "Location"},
+  { 0x0069, "Country"},
+  { 0x006b, "State"},
+  { 0x006d, "City"},
+  { 0x006f, "Landmark"},
+  { 0x0070, "IntelligentResolution"},
+  { 0x0077, "BurstSheed"},
+  { 0x0079, "IntelligentDRange"},
+  { 0x007c, "ClearRetouch"},
+  { 0x0080, "City2"},
+  { 0x0086, "ManometerPressure"},
+  { 0x0089, "PhotoStyle"},
+  { 0x008a, "ShadingCompensation"},
+  { 0x008c, "AccelerometerZ"},
+  { 0x008d, "AccelerometerX"},
+  { 0x008e, "AccelerometerY"},
+  { 0x008f, "CameraOrientation"},
+  { 0x0090, "RollAngle"},
+  { 0x0091, "PitchAngle"},
+  { 0x0093, "SweepPanoramaDirection"},
+  { 0x0094, "PanoramaFieldOfView"},
+  { 0x0096, "TimerRecording"},
+  { 0x009d, "InternalNDFilter"},
+  { 0x009e, "HDR"},
+  { 0x009f, "ShutterType"},
+  { 0x00a3, "ClearRetouchValue"},
+  { 0x00ab, "TouchAE"},
+  { 0x0e00, "PrintIM"},
+  { 0x4449, "0x4449"},
+  { 0x8000, "MakerNoteVersion"},
+  { 0x8001, "SceneMode"},
+  { 0x8004, "WBRedLevel"},
+  { 0x8005, "WBGreenLevel"},
+  { 0x8006, "WBBlueLevel"},
+  { 0x8007, "FlashFired"},
+  { 0x8008, "TextStamp3"},
+  { 0x8009, "TextStamp4"},
+  { 0x8010, "BabyAge2"},
+  { 0x8012, "Transform2"},
+  TAG_TABLE_END
 };
 
 typedef enum mn_byte_order_t {
@@ -1020,7 +1126,8 @@ static const maker_note_type maker_note_array[] = {
   { tag_table_VND_NIKON,     "NIKON",                   NULL,  "Nikon\x00\x01\x00",        8,  8,  MN_ORDER_NORMAL,   MN_OFFSET_NORMAL},
   { tag_table_VND_NIKON_990, "NIKON",                   NULL,  NULL,                       0,  0,  MN_ORDER_NORMAL,   MN_OFFSET_NORMAL},
   { tag_table_VND_OLYMPUS,   "OLYMPUS OPTICAL CO.,LTD", NULL,  "OLYMP\x00\x01\x00",        8,  8,  MN_ORDER_NORMAL,   MN_OFFSET_NORMAL},
-  { tag_table_VND_SAMSUNG,   "SAMSUNG",                 NULL, NULL,                        0,  0,  MN_ORDER_NORMAL,   MN_OFFSET_NORMAL}
+  { tag_table_VND_SAMSUNG,   "SAMSUNG",                 NULL, NULL,                        0,  0,  MN_ORDER_NORMAL,   MN_OFFSET_NORMAL}, 
+  { tag_table_VND_PANASONIC, "Panasonic",               NULL, "Panasonic\x00\x00\x00",     12, 12, MN_ORDER_NORMAL,   MN_OFFSET_NORMAL}
 };
 /* }}} */
 
diff --git a/ext/exif/tests/redhat-bug1362571.jpg b/ext/exif/tests/redhat-bug1362571.jpg
new file mode 100644 (file)
index 0000000..35713e6
Binary files /dev/null and b/ext/exif/tests/redhat-bug1362571.jpg differ
diff --git a/ext/exif/tests/redhat-bug1362571.phpt b/ext/exif/tests/redhat-bug1362571.phpt
new file mode 100644 (file)
index 0000000..ec69e38
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Redhat bug #1362571 (PHP not returning full results for exif_read_data function)
+--SKIPIF--
+<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
+--FILE--
+<?php
+var_dump(strlen(exif_thumbnail(__DIR__ . DIRECTORY_SEPARATOR . 'redhat-bug1362571.jpg')) > 0);
+?>
+--EXPECT--
+bool(true)