| 1 |
/* 'checkit_tiff' is a conformance checker for baseline TIFFs |
| 2 |
* |
| 3 |
* author: Andreas Romeyke, 2015-2022 |
| 4 |
* licensed under conditions of libtiff |
| 5 |
* (see http://libtiff.maptools.org/misc.html) |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "check.h" |
| 10 |
#include "check_helper.h" |
| 11 |
#include "ctstring.h" |
| 12 |
|
| 13 |
/* check if offsets are word aligned */ |
| 14 |
ret_t check_all_offsets_are_word_aligned(ctiff_t * ctif) { |
| 15 |
GET_EMPTY_RET(ret); |
| 16 |
TIFP_CHECK( ctif, ret); |
| 17 |
uint16 count = get_ifd0_count( ctif); |
| 18 |
for (int tagidx = 0; tagidx< count; tagidx++) { |
| 19 |
ifd_entry_t ifd_entry = TIFFGetRawTagIFDListEntry( ctif, ctif->ifd0, tagidx ); |
| 20 |
if (ifd_entry.value_or_offset==is_offset) { |
| 21 |
uint32 offset = ifd_entry.data32offset; |
| 22 |
if ( 0 != (offset & 1)) { |
| 23 |
uint32 tag = TIFFGetRawTagListEntry( ctif, ctif->ifd0, tagidx); |
| 24 |
// FIXME: tif_fails? |
| 25 |
ret = set_value_found_ret_formatted_with_returncode( &ret, tagerror_offset_not_word_aligned, "tag %u pointing to 0x%08x and is not word-aligned", tag, offset); |
| 26 |
return ret; |
| 27 |
} |
| 28 |
} |
| 29 |
} |
| 30 |
ret.returncode=is_valid; |
| 31 |
return ret; |
| 32 |
} |
| 33 |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/ |