summaryrefslogtreecommitdiff
path: root/libtiff/tif_print.c
diff options
context:
space:
mode:
authorSu Laus <sulau@freenet.de>2021-11-26 15:02:35 +0000
committerEven Rouault <even.rouault@spatialys.com>2021-11-26 15:02:35 +0000
commit7db4f2b62206b9cba6cda538e0f296df0ac371bd (patch)
tree395b0eb2770e4b403fc495cde33a96dda7a2d94e /libtiff/tif_print.c
parent29219a5bd14040d60e376324a52ef91b68808143 (diff)
downloadlibtiff-git-7db4f2b62206b9cba6cda538e0f296df0ac371bd.tar.gz
Fix Segmentation fault printing GPS directory if Altitude tag is present (tif_print.c/tiffinfo.c)
Diffstat (limited to 'libtiff/tif_print.c')
-rw-r--r--libtiff/tif_print.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
index 6e9f58ff..5a0305ed 100644
--- a/libtiff/tif_print.c
+++ b/libtiff/tif_print.c
@@ -108,10 +108,16 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip,
fprintf(fd, "%"PRId32, ((int32_t *) raw_data)[j]);
else if(fip->field_type == TIFF_IFD)
fprintf(fd, "0x%"PRIx32, ((uint32_t *) raw_data)[j]);
- else if(fip->field_type == TIFF_RATIONAL
- || fip->field_type == TIFF_SRATIONAL
- || fip->field_type == TIFF_FLOAT)
- fprintf(fd, "%f", ((float *) raw_data)[j]);
+ else if (fip->field_type == TIFF_RATIONAL
+ || fip->field_type == TIFF_SRATIONAL) {
+ int tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
+ if(tv_size==8)
+ fprintf(fd, "%lf", ((double*)raw_data)[j]);
+ else
+ fprintf(fd, "%f", ((float *) raw_data)[j]);
+ }
+ else if(fip->field_type == TIFF_FLOAT)
+ fprintf(fd, "%f", ((float*)raw_data)[j]);
else if(fip->field_type == TIFF_LONG8)
fprintf(fd, "%"PRIu64, ((uint64_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SLONG8)
@@ -238,7 +244,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
char *sep;
long l, n;
- fprintf(fd, "TIFF Directory at offset 0x%"PRIu64" (%"PRIx64")\n",
+ fprintf(fd, "TIFF Directory at offset 0x%"PRIx64" (%"PRIu64")\n",
tif->tif_diroff,
tif->tif_diroff);
if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) {
@@ -614,8 +620,10 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
if(TIFFGetField(tif, tag, &raw_data) != 1)
continue;
} else {
+ /*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */
+ int tv_size = _TIFFSetGetFieldSize(fip->set_field_type);
raw_data = _TIFFmalloc(
- _TIFFDataSize(fip->field_type)
+ tv_size
* value_count);
mem_alloc = 1;
if(TIFFGetField(tif, tag, raw_data) != 1) {