From 7a299784ea81764358910f47093beeab5f962712 Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Tue, 7 Mar 2023 22:31:59 +0100 Subject: [PATCH] Make libtiff not crash on scary unknown numbers --- postprocess.c | 18 ++++++++++++++---- postprocess.h | 38 ++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/postprocess.c b/postprocess.c index 108d54b..de34eed 100644 --- a/postprocess.c +++ b/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, diff --git a/postprocess.h b/postprocess.h index 0e790e3..6b3f74e 100644 --- a/postprocess.h +++ b/postprocess.h @@ -4,26 +4,32 @@ #include #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 -- 2.45.2