浏览代码

Make libtiff not crash on scary unknown numbers

Martijn Braam 2 年之前
父节点
当前提交
7a299784ea
共有 2 个文件被更改,包括 36 次插入20 次删除
  1. 14 4
      postprocess.c
  2. 22 16
      postprocess.h

+ 14 - 4
postprocess.c

@@ -13,10 +13,20 @@
 static void
 register_custom_tiff_tags(TIFF *tif)
 {
-    static const TIFFFieldInfo custom_fields[] = {
-        {TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
-            "ForwardMatrix1"},
-    };
+	static const TIFFFieldInfo custom_fields[] = {
+		{DCPTAG_FORWARD_MATRIX_1,           -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ForwardMatrix1"},
+		{DCPTAG_FORWARD_MATRIX_2,           -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ForwardMatrix2"},
+		{DCPTAG_PROFILE_TONE_CURVE,         -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ProfileToneCurve"},
+		{DCPTAG_PROFILE_HUE_SAT_MAP_DIMS,   -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ProfileHueSatMapDims"},
+		{DCPTAG_PROFILE_HUE_SAT_MAP_DATA_1, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ProfileHueSatMapData1"},
+		{DCPTAG_PROFILE_HUE_SAT_MAP_DATA_2, -1, -1, TIFF_SRATIONAL, FIELD_CUSTOM, 1, 1,
+			"ProfileHueSatMapData2"},
+	};
 
     // Add missing dng fields
     TIFFMergeFieldInfo(tif, custom_fields,

+ 22 - 16
postprocess.h

@@ -4,26 +4,32 @@
 #include <stdint.h>
 #include "util.h"
 
-#define TIFFTAG_FORWARDMATRIX1 50964
+#define DCPTAG_PROFILE_HUE_SAT_MAP_DIMS 50937
+#define DCPTAG_PROFILE_HUE_SAT_MAP_DATA_1 50938
+#define DCPTAG_PROFILE_HUE_SAT_MAP_DATA_2 50939
+#define DCPTAG_PROFILE_TONE_CURVE 50940
+#define DCPTAG_FORWARD_MATRIX_1 50964
+#define DCPTAG_FORWARD_MATRIX_2 50965
+
 
 #define JPEG_APP1 JPEG_APP0+1
 
 struct Imagedata {
-        uint32_t width;
-        uint32_t height;
-        uint8_t bitspersample;
-        char *make;
-        char *model;
-        char *software;
-        int orientation;
-        char *datetime;
-        uint16_t exposure_program;
-        float exposure_time;
-        uint16_t isospeed;
-        int flash;
-        float fnumber;
-        float focal_length;
-        uint16_t focal_length_35mm;
+		uint32_t width;
+		uint32_t height;
+		uint8_t bitspersample;
+		char *make;
+		char *model;
+		char *software;
+		int orientation;
+		char *datetime;
+		uint16_t exposure_program;
+		float exposure_time;
+		uint16_t isospeed;
+		int flash;
+		float fnumber;
+		float focal_length;
+		uint16_t focal_length_35mm;
 };
 
 void