Browse Source

- optimized includes

- bugfix, in read_offsetdata(), TIFFGetField...() avoid using negative value for uint32
- added type cast fixes
development
Andreas Romeyke 8 months ago
parent
commit
519046eed6
1 changed files with 10 additions and 13 deletions
  1. +10
    -13
      src/helper/check_tiffparse.c

+ 10
- 13
src/helper/check_tiffparse.c View File

@ -10,11 +10,8 @@
#include <math.h>
#include "check.h"
#include "check_helper.h"
#include "msg_tiffparse.h"
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#ifdef _HAVE__MMAP
#include <sys/mman.h>
@ -421,7 +418,7 @@ ret_t read_offsetdata(ctiff_t * ctif, const uint32 address, const uint32 count,
ret_p->returncode = is_valid;
/* ct_read and seek to IFD address */
if (ct_seek(ctif, address, SEEK_SET) != (off_t) address) {
offset_p->count = -1;
offset_p->count = 0;
ret_p->returncode = tiff_seek_error_offset;
return * ret_p;
}
@ -571,10 +568,10 @@ ifd_entry_t TIFFGetRawTagIFDListEntry( ctiff_t * ctif, int tagidx ) {
ifd_entry.data32offset=value_or_offset;
} else { /* values */
ifd_entry.value_or_offset=is_value;
ifd_entry.data8[0] = value_or_offset & 0x000000ff;
ifd_entry.data8[1] = (value_or_offset >> 8) & 0x000000ff;
ifd_entry.data8[2] = (value_or_offset >> 16) & 0x000000ff;
ifd_entry.data8[3] = (value_or_offset >> 24) & 0x000000ff;
ifd_entry.data8[0] = (uint8) (value_or_offset & 0x000000ff);
ifd_entry.data8[1] = (uint8) ((value_or_offset >> 8) & 0x000000ff);
ifd_entry.data8[2] = (uint8) ((value_or_offset >> 16) & 0x000000ff);
ifd_entry.data8[3] = (uint8) ((value_or_offset >> 24) & 0x000000ff);
#ifdef DEBUG
printf("data8[0]=%u\n", ifd_entry.data8[0] );
printf("data8[1]=%u\n", ifd_entry.data8[1] );
@ -593,8 +590,8 @@ ifd_entry_t TIFFGetRawTagIFDListEntry( ctiff_t * ctif, int tagidx ) {
if (byteswapped) {
TIFFSwabLong( &value_or_offset);
}
uint16 w0 = value_or_offset & 0x0000ffff;
uint16 w1 = (value_or_offset >> 16) & 0x0000ffff;;
uint16 w0 = (uint16) (value_or_offset & 0x0000ffff);
uint16 w1 = (uint16) ((value_or_offset >> 16) & 0x0000ffff);;
if (byteswapped) { /* swap correctly 16bit */
TIFFSwabShort( &w0 );
TIFFSwabShort( &w1 );
@ -712,7 +709,7 @@ ctiff_t * initialize_ctif(const char * tiff_file, ct_ioflag_t ioflag) {
exit (EXIT_FAILURE);
};
ctif->fd = tif;
ctif->streamlen = fsize(tif);
ctif->streamlen = (uint32) fsize(tif);
ctif->streamp = NULL;
ctif->actual_streamp = NULL;
ctif->tagorder=unknown_tag_order;
@ -879,7 +876,7 @@ ret_t TIFFGetFieldASCII(ctiff_t * ctif, const tag_t tag, char** string_pp, uint3
ret_t TIFFGetFieldLONG(ctiff_t * ctif, const tag_t tag, uint32 ** long_pp, uint32 * countp) {
assert( *long_pp == NULL);
assert( countp != NULL);
*countp = -1; /* init */
*countp = 0; /* init */
GET_EMPTY_RET(ret)
int tagidx = TIFFGetRawTagListIndex(ctif, tag);
if (tagidx >= 0) { /* there exists the tag */
@ -936,7 +933,7 @@ ret_t TIFFGetFieldLONG(ctiff_t * ctif, const tag_t tag, uint32 ** long_pp, uint3
ret_t TIFFGetFieldSHORT(ctiff_t * ctif, const tag_t tag, uint16 ** short_pp, uint32 * countp) {
assert( *short_pp == NULL);
assert( countp != NULL);
*countp = -1; /* init */
*countp = 0; /* init */
GET_EMPTY_RET(ret)
int tagidx = TIFFGetRawTagListIndex(ctif, tag);
if (tagidx >= 0) { /* there exists the tag */


Loading…
Cancel
Save