]> granicus.if.org Git - php/commitdiff
Fixed bug #72735 (Samsung picture thumb not read (zero size))
authorKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Aug 2016 08:02:22 +0000 (10:02 +0200)
committerKalle Sommer Nielsen <kalle@php.net>
Wed, 3 Aug 2016 08:02:22 +0000 (10:02 +0200)
It seems like there is no maker data for "Samsung", this causes the IDF tag parsing to fail, and it bails early on, despite there still is valid remaining data in image, such as the thumbnail data as reported in the bug.

I used the Exiv2 website as a reference guide for tags that's specific to Samsung's EXIF data, which should also mean that we will be able to name some of those tags more specifically now.

I have chosen again not to commit this to other branches, simply because I'm not 100% sure on the byte order and offsets for Samsung, I did some research and it seems like there are many variants, but this (very copy/pasted), entry works for this particular image and does not break any other tests. This does add a new feature I suppose, while also fixing a bug, but I will leave it to the other branch RMs to decide on how far down they will want to merge this.

ext/exif/exif.c
ext/exif/tests/bug72735/bug72735.phpt [new file with mode: 0644]
ext/exif/tests/bug72735/nokia.jpg [new file with mode: 0644]
ext/exif/tests/bug72735/samsung.jpg [new file with mode: 0644]

index 9f951d78a35d13dd954b0af5ce83d69564be85bb..e08509a08150594d647d95392112d9ffac18f651 100644 (file)
@@ -955,6 +955,40 @@ 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
+};
+
 typedef enum mn_byte_order_t {
        MN_ORDER_INTEL    = 0,
        MN_ORDER_MOTOROLA = 1,
@@ -986,6 +1020,7 @@ 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}
 };
 /* }}} */
 
@@ -2711,7 +2746,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))
                        return FALSE;
@@ -2726,7 +2761,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);
diff --git a/ext/exif/tests/bug72735/bug72735.phpt b/ext/exif/tests/bug72735/bug72735.phpt
new file mode 100644 (file)
index 0000000..24b2a04
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #72735 (Samsung picture thumb not read (zero size))
+--SKIPIF--
+<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
+--FILE--
+<?php
+foreach (['nokia.jpg', 'samsung.jpg'] as $picture) {
+       echo $picture . ': ';
+
+       $len = strlen(exif_thumbnail(__DIR__ . DIRECTORY_SEPARATOR . $picture));
+
+       if (!$len) {
+               echo 'Error, no length returned', PHP_EOL;
+
+               continue;
+       }
+
+       echo 'int(' . $len . ')', PHP_EOL;
+} 
+?>
+--EXPECTF--
+nokia.jpg: int(5899)
+samsung.jpg: int(5778)
diff --git a/ext/exif/tests/bug72735/nokia.jpg b/ext/exif/tests/bug72735/nokia.jpg
new file mode 100644 (file)
index 0000000..48367bf
Binary files /dev/null and b/ext/exif/tests/bug72735/nokia.jpg differ
diff --git a/ext/exif/tests/bug72735/samsung.jpg b/ext/exif/tests/bug72735/samsung.jpg
new file mode 100644 (file)
index 0000000..7009606
Binary files /dev/null and b/ext/exif/tests/bug72735/samsung.jpg differ