From ff993722c93e690f9cd4e2fc20c5b87c245a3fc1 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Wed, 2 Oct 2002 08:46:54 +0000 Subject: [PATCH] Another fix for the fetching SBYTE arrays by the TIFFFetchByteArray() function. Should finally resolve http://bugzilla.remotesensing.org/show_bug.cgi?id=52 --- ChangeLog | 7 ++++++ libtiff/tif_dirread.c | 54 +++++++++++++++++++++++++------------------ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08aa9cbc..a984ad94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-10-02 Andrey Kiselev + + * libtiff/tif_dirread.c: Another fix for the fetching SBYTE arrays + by the TIFFFetchByteArray() function. Should finally resolve + + http://bugzilla.remotesensing.org/show_bug.cgi?id=52 + 2002-09-15 Andrey Kiselev * Makefile.in, /man/{raw2tiff.1, Makefile.in, libtiff.3}: Added diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index b751d9f2..0e6ab8b5 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v 1.12 2002-09-08 18:01:20 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dirread.c,v 1.13 2002-10-02 08:46:54 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -780,28 +780,36 @@ TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) * Extract data from offset field. */ if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { - switch (dir->tdir_count) { - case 4: v[3] = (uint16)(dir->tdir_offset & 0xff); - case 3: v[2] = (uint16)((dir->tdir_offset >> 8) & 0xff); - case 2: v[1] = (uint16)((dir->tdir_offset >> 16) & 0xff); - case 1: - if (dir->tdir_type == TIFF_SBYTE) - v[0] = (signed char)(dir->tdir_offset >> 24); - else - v[0] = (uint16)(dir->tdir_offset >> 24); - } - } else { - switch (dir->tdir_count) { - case 4: v[3] = (uint16)(dir->tdir_offset >> 24); - case 3: v[2] = (uint16)((dir->tdir_offset >> 16) & 0xff); - case 2: v[1] = (uint16)((dir->tdir_offset >> 8) & 0xff); - case 1: - if (dir->tdir_type == TIFF_SBYTE) - v[0] = (signed char)((dir->tdir_offset) & 0xff); - else - v[0] = (uint16)(dir->tdir_offset & 0xff); - } - } + if (dir->tdir_type == TIFF_SBYTE) + switch (dir->tdir_count) { + case 4: v[3] = (signed char)(dir->tdir_offset & 0xff); + case 3: v[2] = (signed char)((dir->tdir_offset >> 8) & 0xff); + case 2: v[1] = (signed char)((dir->tdir_offset >> 16) & 0xff); + case 1: v[0] = (signed char)(dir->tdir_offset >> 24); + } + else + switch (dir->tdir_count) { + case 4: v[3] = (uint16)(dir->tdir_offset & 0xff); + case 3: v[2] = (uint16)((dir->tdir_offset >> 8) & 0xff); + case 2: v[1] = (uint16)((dir->tdir_offset >> 16) & 0xff); + case 1: v[0] = (uint16)(dir->tdir_offset >> 24); + } + } else { + if (dir->tdir_type == TIFF_SBYTE) + switch (dir->tdir_count) { + case 4: v[3] = (signed char)(dir->tdir_offset >> 24); + case 3: v[2] = (signed char)((dir->tdir_offset >> 16) & 0xff); + case 2: v[1] = (signed char)((dir->tdir_offset >> 8) & 0xff); + case 1: v[0] = (signed char)(dir->tdir_offset & 0xff); + } + else + switch (dir->tdir_count) { + case 4: v[3] = (uint16)(dir->tdir_offset >> 24); + case 3: v[2] = (uint16)((dir->tdir_offset >> 16) & 0xff); + case 2: v[1] = (uint16)((dir->tdir_offset >> 8) & 0xff); + case 1: v[0] = (uint16)(dir->tdir_offset & 0xff); + } + } return (1); } else return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */