diff options
Diffstat (limited to 'ext/exif/exif.c')
-rw-r--r-- | ext/exif/exif.c | 420 |
1 files changed, 403 insertions, 17 deletions
diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 1c2db35f36..c882a12c7c 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -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) @@ -136,7 +136,16 @@ PHP_MINFO_FUNCTION(exif) php_info_print_table_row(2, "EXIF Support", "enabled"); php_info_print_table_row(2, "EXIF Version", PHP_EXIF_VERSION); php_info_print_table_row(2, "Supported EXIF Version", "0220"); - php_info_print_table_row(2, "Supported filetypes", "JPEG,TIFF"); + php_info_print_table_row(2, "Supported filetypes", "JPEG, TIFF"); + + if (zend_hash_str_exists(&module_registry, "mbstring", sizeof("mbstring")-1)) { + php_info_print_table_row(2, "Multibyte decoding support using mbstring", "enabled"); + } else { + php_info_print_table_row(2, "Multibyte decoding support using mbstring", "disabled"); + } + + php_info_print_table_row(2, "Extended EXIF tag formats", "Canon, Casio, Fujifilm, Nikon, Olympus, Samsung, Panasonic, DJI, Sony, Pentax, Minolta, Sigma, Foveon"); + php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } @@ -171,7 +180,7 @@ ZEND_INI_MH(OnUpdateEncode) php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", ZSTR_VAL(new_value)); return FAILURE; } - efree(return_list); + pefree((void *) return_list, 0); } return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } @@ -186,7 +195,7 @@ ZEND_INI_MH(OnUpdateDecode) php_error_docref(NULL, E_WARNING, "Illegal encoding ignored: '%s'", ZSTR_VAL(new_value)); return FAILURE; } - efree(return_list); + pefree((void *) return_list, 0); } return OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); } @@ -218,7 +227,7 @@ static PHP_GINIT_FUNCTION(exif) /* }}} */ /* {{{ PHP_MINIT_FUNCTION(exif) - Get the size of an image as 4-element array */ + */ PHP_MINIT_FUNCTION(exif) { REGISTER_INI_ENTRIES(); @@ -955,6 +964,360 @@ static tag_info_array tag_table_VND_OLYMPUS = { TAG_TABLE_END }; +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 +}; + +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 +}; + +static tag_info_array tag_table_VND_DJI = { + { 0x0001, "Make"}, + { 0x0003, "SpeedX"}, + { 0x0004, "SpeedY"}, + { 0x0005, "SpeedZ"}, + { 0x0006, "Pitch"}, + { 0x0007, "Yaw"}, + { 0x0008, "Roll"}, + { 0x0009, "CameraPitch"}, + { 0x000a, "CameraYaw"}, + { 0x000b, "CameraRoll"}, + TAG_TABLE_END +}; + +static tag_info_array tag_table_VND_SONY = { + { 0x0102, "Quality"}, + { 0x0104, "FlashExposureComp"}, + { 0x0105, "Teleconverter"}, + { 0x0112, "WhiteBalanceFineTune"}, + { 0x0114, "CameraSettings"}, + { 0x0115, "WhiteBalance"}, + { 0x0116, "0x0116"}, + { 0x0e00, "PrintIM"}, + { 0x1000, "MultiBurstMode"}, + { 0x1001, "MultiBurstImageWidth"}, + { 0x1002, "MultiBurstImageHeight"}, + { 0x1003, "Panorama"}, + { 0x2000, "0x2000"}, + { 0x2001, "PreviewImage"}, + { 0x2002, "0x2002"}, + { 0x2003, "0x2003"}, + { 0x2004, "Contrast"}, + { 0x2005, "Saturation"}, + { 0x2006, "0x2006"}, + { 0x2007, "0x2007"}, + { 0x2008, "0x2008"}, + { 0x2009, "0x2009"}, + { 0x200a, "AutoHDR"}, + { 0x3000, "ShotInfo"}, + { 0xb000, "FileFormat"}, + { 0xb001, "SonyModelID"}, + { 0xb020, "ColorReproduction"}, + { 0xb021, "ColorTemperature"}, + { 0xb022, "ColorCompensationFilter"}, + { 0xb023, "SceneMode"}, + { 0xb024, "ZoneMatching"}, + { 0xb025, "DynamicRangeOptimizer"}, + { 0xb026, "ImageStabilization"}, + { 0xb027, "LensID"}, + { 0xb028, "MinoltaMakerNote"}, + { 0xb029, "ColorMode"}, + { 0xb02b, "FullImageSize"}, + { 0xb02c, "PreviewImageSize"}, + { 0xb040, "Macro"}, + { 0xb041, "ExposureMode"}, + { 0xb042, "FocusMode"}, + { 0xb043, "AFMode"}, + { 0xb044, "AFIlluminator"}, + { 0xb047, "JPEGQuality"}, + { 0xb048, "FlashLevel"}, + { 0xb049, "ReleaseMode"}, + { 0xb04a, "SequenceNumber"}, + { 0xb04b, "AntiBlur"}, + { 0xb04e, "LongExposureNoiseReduction"}, + { 0xb04f, "DynamicRangeOptimizer"}, + { 0xb052, "IntelligentAuto"}, + { 0xb054, "WhiteBalance2"}, + TAG_TABLE_END +}; + +static tag_info_array tag_table_VND_PENTAX = { + { 0x0000, "Version"}, + { 0x0001, "Mode"}, + { 0x0002, "PreviewResolution"}, + { 0x0003, "PreviewLength"}, + { 0x0004, "PreviewOffset"}, + { 0x0005, "ModelID"}, + { 0x0006, "Date"}, + { 0x0007, "Time"}, + { 0x0008, "Quality"}, + { 0x0009, "Size"}, + { 0x000c, "Flash"}, + { 0x000d, "Focus"}, + { 0x000e, "AFPoint"}, + { 0x000f, "AFPointInFocus"}, + { 0x0012, "ExposureTime"}, + { 0x0013, "FNumber"}, + { 0x0014, "ISO"}, + { 0x0016, "ExposureCompensation"}, + { 0x0017, "MeteringMode"}, + { 0x0018, "AutoBracketing"}, + { 0x0019, "WhiteBalance"}, + { 0x001a, "WhiteBalanceMode"}, + { 0x001b, "BlueBalance"}, + { 0x001c, "RedBalance"}, + { 0x001d, "FocalLength"}, + { 0x001e, "DigitalZoom"}, + { 0x001f, "Saturation"}, + { 0x0020, "Contrast"}, + { 0x0021, "Sharpness"}, + { 0x0022, "Location"}, + { 0x0023, "Hometown"}, + { 0x0024, "Destination"}, + { 0x0025, "HometownDST"}, + { 0x0026, "DestinationDST"}, + { 0x0027, "DSPFirmwareVersion"}, + { 0x0028, "CPUFirmwareVersion"}, + { 0x0029, "FrameNumber"}, + { 0x002d, "EffectiveLV"}, + { 0x0032, "ImageProcessing"}, + { 0x0033, "PictureMode"}, + { 0x0034, "DriveMode"}, + { 0x0037, "ColorSpace"}, + { 0x0038, "ImageAreaOffset"}, + { 0x0039, "RawImageSize"}, + { 0x003e, "PreviewImageBorders"}, + { 0x003f, "LensType"}, + { 0x0040, "SensitivityAdjust"}, + { 0x0041, "DigitalFilter"}, + { 0x0047, "Temperature"}, + { 0x0048, "AELock"}, + { 0x0049, "NoiseReduction"}, + { 0x004d, "FlashExposureCompensation"}, + { 0x004f, "ImageTone"}, + { 0x0050, "ColorTemperature"}, + { 0x005c, "ShakeReduction"}, + { 0x005d, "ShutterCount"}, + { 0x0069, "DynamicRangeExpansion"}, + { 0x0071, "HighISONoiseReduction"}, + { 0x0072, "AFAdjustment"}, + { 0x0200, "BlackPoint"}, + { 0x0201, "WhitePoint"}, + { 0x0205, "ShotInfo"}, + { 0x0206, "AEInfo"}, + { 0x0207, "LensInfo"}, + { 0x0208, "FlashInfo"}, + { 0x0209, "AEMeteringSegments"}, + { 0x020a, "FlashADump"}, + { 0x020b, "FlashBDump"}, + { 0x020d, "WB_RGGBLevelsDaylight"}, + { 0x020e, "WB_RGGBLevelsShade"}, + { 0x020f, "WB_RGGBLevelsCloudy"}, + { 0x0210, "WB_RGGBLevelsTungsten"}, + { 0x0211, "WB_RGGBLevelsFluorescentD"}, + { 0x0212, "WB_RGGBLevelsFluorescentN"}, + { 0x0213, "WB_RGGBLevelsFluorescentW"}, + { 0x0214, "WB_RGGBLevelsFlash"}, + { 0x0215, "CameraInfo"}, + { 0x0216, "BatteryInfo"}, + { 0x021f, "AFInfo"}, + { 0x0222, "ColorInfo"}, + { 0x0229, "SerialNumber"}, + TAG_TABLE_END +}; + +static tag_info_array tag_table_VND_MINOLTA = { + { 0x0000, "Version"}, + { 0x0001, "CameraSettingsStdOld"}, + { 0x0003, "CameraSettingsStdNew"}, + { 0x0004, "CameraSettings7D"}, + { 0x0018, "ImageStabilizationData"}, + { 0x0020, "WBInfoA100"}, + { 0x0040, "CompressedImageSize"}, + { 0x0081, "Thumbnail"}, + { 0x0088, "ThumbnailOffset"}, + { 0x0089, "ThumbnailLength"}, + { 0x0100, "SceneMode"}, + { 0x0101, "ColorMode"}, + { 0x0102, "Quality"}, + { 0x0103, "0x0103"}, + { 0x0104, "FlashExposureComp"}, + { 0x0105, "Teleconverter"}, + { 0x0107, "ImageStabilization"}, + { 0x0109, "RawAndJpgRecording"}, + { 0x010a, "ZoneMatching"}, + { 0x010b, "ColorTemperature"}, + { 0x010c, "LensID"}, + { 0x0111, "ColorCompensationFilter"}, + { 0x0112, "WhiteBalanceFineTune"}, + { 0x0113, "ImageStabilizationA100"}, + { 0x0114, "CameraSettings5D"}, + { 0x0115, "WhiteBalance"}, + { 0x0e00, "PrintIM"}, + { 0x0f00, "CameraSettingsZ1"}, + TAG_TABLE_END +}; + +static tag_info_array tag_table_VND_SIGMA = { + { 0x0002, "SerialNumber"}, + { 0x0003, "DriveMode"}, + { 0x0004, "ResolutionMode"}, + { 0x0005, "AutofocusMode"}, + { 0x0006, "FocusSetting"}, + { 0x0007, "WhiteBalance"}, + { 0x0008, "ExposureMode"}, + { 0x0009, "MeteringMode"}, + { 0x000a, "LensRange"}, + { 0x000b, "ColorSpace"}, + { 0x000c, "Exposure"}, + { 0x000d, "Contrast"}, + { 0x000e, "Shadow"}, + { 0x000f, "Highlight"}, + { 0x0010, "Saturation"}, + { 0x0011, "Sharpness"}, + { 0x0012, "FillLight"}, + { 0x0014, "ColorAdjustment"}, + { 0x0015, "AdjustmentMode"}, + { 0x0016, "Quality"}, + { 0x0017, "Firmware"}, + { 0x0018, "Software"}, + { 0x0019, "AutoBracket"}, + TAG_TABLE_END +}; + typedef enum mn_byte_order_t { MN_ORDER_INTEL = 0, MN_ORDER_MOTOROLA = 1, @@ -978,14 +1341,22 @@ typedef struct { mn_offset_mode_t offset_mode; } maker_note_type; +/* Remember to update PHP_MINFO if updated */ static const maker_note_type maker_note_array[] = { { tag_table_VND_CANON, "Canon", NULL, NULL, 0, 0, MN_ORDER_INTEL, MN_OFFSET_GUESS}, -/* { tag_table_VND_CANON, "Canon", NULL, NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},*/ { tag_table_VND_CASIO, "CASIO", NULL, NULL, 0, 0, MN_ORDER_MOTOROLA, MN_OFFSET_NORMAL}, { tag_table_VND_FUJI, "FUJIFILM", NULL, "FUJIFILM\x0C\x00\x00\x00", 12, 12, MN_ORDER_INTEL, MN_OFFSET_MAKER}, { 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_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_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}, + { tag_table_VND_SIGMA, "SIGMA, FOVEON", NULL, "FOVEON\x00\x00\x00", 10, 10, MN_ORDER_NORMAL, MN_OFFSET_NORMAL} }; /* }}} */ @@ -1270,6 +1641,20 @@ static double exif_convert_any_format(void *value, int format, int motorola_inte } /* }}} */ +/* {{{ exif_rewrite_tag_format_to_unsigned + * Rewrite format tag so that it specifies an unsigned type for a tag */ +static int exif_rewrite_tag_format_to_unsigned(int format) +{ + switch(format) { + case TAG_FMT_SBYTE: return TAG_FMT_BYTE; + case TAG_FMT_SRATIONAL: return TAG_FMT_URATIONAL; + case TAG_FMT_SSHORT: return TAG_FMT_USHORT; + case TAG_FMT_SLONG: return TAG_FMT_ULONG; + } + return format; +} +/* }}} */ + /* {{{ exif_convert_any_to_int * Evaluate number, be it int, rational, or float from directory. */ static size_t exif_convert_any_to_int(void *value, int format, int motorola_intel) @@ -1704,7 +2089,7 @@ static void exif_iif_add_value(image_info_type *image_info, int section_index, c case TAG_FMT_UNDEFINED: if (value) { if (tag == TAG_MAKER_NOTE) { - length = MIN(length, strlen(value)); + length = MIN(length, (int) strlen(value)); } /* do not recompute length here */ @@ -2715,7 +3100,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu int NumDirEntries, old_motorola_intel, offset_diff; const maker_note_type *maker_note; char *dir_start; - + for (i=0; i<=sizeof(maker_note_array)/sizeof(maker_note_type); i++) { if (i==sizeof(maker_note_array)/sizeof(maker_note_type)) { #ifdef EXIF_DEBUG @@ -2736,7 +3121,7 @@ static int exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * valu continue; break; } - + if (maker_note->offset >= value_len) { /* Do not go past the value end */ exif_error_docref("exif_read_data#error_ifd" EXIFERR_CC, ImageInfo, E_WARNING, "IFD data too short: 0x%04X offset 0x%04X", value_len, maker_note->offset); @@ -2844,7 +3229,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(%ld)", tag, exif_get_tagname(tag, tagname, -12, tag_table), components); return FALSE; } @@ -2933,18 +3318,18 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha switch(tag) { case TAG_IMAGEWIDTH: case TAG_COMP_IMAGE_WIDTH: - ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->Thumbnail.width = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); break; case TAG_IMAGEHEIGHT: case TAG_COMP_IMAGE_HEIGHT: - ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->Thumbnail.height = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); break; case TAG_STRIP_OFFSETS: case TAG_JPEG_INTERCHANGE_FORMAT: /* accept both formats */ - ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->Thumbnail.offset = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); break; case TAG_STRIP_BYTE_COUNTS: @@ -2954,13 +3339,13 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha /* motorola is easier to read */ ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_TIFF_MM; } - ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); break; case TAG_JPEG_INTERCHANGE_FORMAT_LEN: if (ImageInfo->Thumbnail.filetype == IMAGE_FILETYPE_UNKNOWN) { ImageInfo->Thumbnail.filetype = IMAGE_FILETYPE_JPEG; - ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->Thumbnail.size = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); } break; } @@ -3032,7 +3417,7 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha break; case TAG_COMP_IMAGE_WIDTH: - ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, format, ImageInfo->motorola_intel); + ImageInfo->ExifImageWidth = exif_convert_any_to_int(value_ptr, exif_rewrite_tag_format_to_unsigned(format), ImageInfo->motorola_intel); break; case TAG_FOCALPLANE_X_RES: @@ -3725,6 +4110,7 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse if (fgot < ImageInfo->Thumbnail.size) { EXIF_ERRLOG_THUMBEOF(ImageInfo) efree(ImageInfo->Thumbnail.data); + ImageInfo->Thumbnail.data = NULL; } else { exif_thumbnail_build(ImageInfo); @@ -4204,7 +4590,7 @@ PHP_FUNCTION(exif_imagetype) php_stream * stream; int itype = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &imagefile, &imagefile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &imagefile, &imagefile_len) == FAILURE) { return; } |