Browse Source

- added check_cardinality_of_some_tags_are_equal()

tags/v0.6.0^2
Andreas Romeyke 2 months ago
parent
commit
d8f49012b2
6 changed files with 50 additions and 3 deletions
  1. +2
    -2
      src/headers/check.h
  2. +1
    -0
      src/headers/config_parser.h
  3. +40
    -0
      src/ifdrules/check_tags_with_corresponding_cardinality.c
  4. +3
    -0
      src/messages/msg_parser.c
  5. +4
    -1
      src/parser/config_parser.c
  6. BIN
      tiffs_should_fail/minimal_different_cardinality_of_stripoffsets_and_stripbytescount.tiff

+ 2
- 2
src/headers/check.h View File

@@ -129,8 +129,7 @@ typedef enum {
parser_logical_combine_open, /* if fc_logicalcombine was called first (no error) */
parser_logical_combine_close, /* if fc_logicalcombine was called first (no error) */
tagerror_offset_is_zero,


ifderror_different_cardinality,
} returncode_t;

typedef struct ret_s {
@@ -282,6 +281,7 @@ ret_t check_all_offsets_are_used_once_only(ctiff_t * ctif);
ret_t check_all_offsets_are_greater_zero(ctiff_t * ctif);
ret_t check_all_IFDs_are_word_aligned(ctiff_t * ctif);
ret_t check_all_geotiff_tags( ctiff_t * ctif);
ret_t check_cardinality_of_some_tags_are_equal( ctiff_t * ctif);

mem_map_t * scan_mem_map(ctiff_t * ctif) ;
void print_mem_map( mem_map_t * memmap_p);


+ 1
- 0
src/headers/config_parser.h View File

@@ -58,6 +58,7 @@ typedef enum {
fc_internal_logic_combine_close,
fc_all_offsets_are_not_zero,
fc_all_geotiff_tags_have_same_count_of_values,
fc_check_cardinality,
fc_dummy
} function_t;



+ 40
- 0
src/ifdrules/check_tags_with_corresponding_cardinality.c View File

@@ -0,0 +1,40 @@
/* rule based checks if given TIFF is a specific baseline TIFF
*
* author: Andreas Romeyke, 2020
* licensed under conditions of libtiff
* (see http://libtiff.maptools.org/misc.html)
*
*/

#include "check.h"
#include "check_helper.h"
#include <unistd.h>


/* check if cardinality of tags are equal */
ret_t check_cardinality_of_some_tags_are_equal(ctiff_t * ctif) {
/* we need to check following tag groups:
* StripOffset and StripBytesCounts
*/
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
/* check if both values exist */
ret_t rc=check_tag_quiet(ctif, TIFFTAG_STRIPOFFSETS);
if (rc.returncode != is_valid) return rc;
rc=check_tag_quiet(ctif, TIFFTAG_STRIPBYTECOUNTS);
if (rc.returncode != is_valid) return rc;

/* find stripoffset */
ifd_entry_t stripoffsets_entry = TIFFGetRawIFDEntry(ctif, TIFFTAG_STRIPOFFSETS);
ifd_entry_t stripbytescounts_entry = TIFFGetRawIFDEntry(ctif, TIFFTAG_STRIPBYTECOUNTS);
if (stripoffsets_entry.count != stripbytescounts_entry.count) {
char array[TIFFAILSTRLEN];
snprintf(array, sizeof(array), "tag %u count=%u, tag %u count=%u", TIFFTAG_STRIPOFFSETS, stripoffsets_entry.count, TIFFTAG_STRIPBYTECOUNTS, stripbytescounts_entry.count);
ret = set_value_found_ret(&ret, array);
ret.returncode = ifderror_different_cardinality;
return ret;
}
ret.returncode=is_valid;
return ret;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/

+ 3
- 0
src/messages/msg_parser.c View File

@@ -34,6 +34,7 @@ const char * get_parser_function_name( function_t f ) {
case fc_internal_logic_combine_close: return "fc_internal_logic_combine_close"; break;
case fc_all_offsets_are_not_zero: return "fc_all_offsets_are_not_zero"; break;
case fc_all_geotiff_tags_have_same_count_of_values: return "fc_all_geotiff_tags_have_same_count_of_values"; break;
case fc_check_cardinality: return "fc_check_cardinality"; break;
case fc_dummy: return "fc_dummy"; break;
}
return "missed function description, should not occur";
@@ -65,6 +66,7 @@ const char * get_parser_function_description( function_t f ) {
case fc_internal_logic_combine_close: return "One or more conditions needs to be combined in a logical_or operation (close)"; break;
case fc_all_offsets_are_not_zero: return "All tag offsets should be greater than zero,"; break;
case fc_all_geotiff_tags_have_same_count_of_values: return "All GeoTIFF tags should have same amount of values,"; break;
case fc_check_cardinality: return "Cardinality of tags should be equal,"; break;
case fc_dummy: return "Dummy."; break;
}
return "missed function description, should not occur";
@@ -130,6 +132,7 @@ const char * get_parser_error_description( returncode_t r ) {
case tagerror_offset_is_zero: return "but an offset zero is used."; break;
case tagerror_expected_count_not_a_multiple_of_four: return "unexpected tag count value, should be a multiple of four."; break;
case tagerror_expected_count_less_than_four: return "unexpected tag count value, should be at least four."; break;
case ifderror_different_cardinality: return "but counts of values are different."; break;
}
assert( r == is_valid ); /* missed error description, should not occur */
return "missed error description, should not occur";


+ 4
- 1
src/parser/config_parser.c View File

@@ -390,9 +390,10 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep)
case fc_internal_logic_combine_open: { ret.returncode = parser_logical_combine_open ; break; }
case fc_internal_logic_combine_close: { ret.returncode = parser_logical_combine_close ; break; }
case fc_all_offsets_are_not_zero: { ret = check_all_offsets_are_greater_zero(ctif); break;}
case fc_all_geotiff_tags_have_same_count_of_values: {
case fc_all_geotiff_tags_have_same_count_of_values: {
ret = check_all_geotiff_tags(ctif); break;
}
case fc_check_cardinality: { ret = check_cardinality_of_some_tags_are_equal(ctif); break;}

default: {
GET_EMPTY_RET(res)
@@ -1112,6 +1113,8 @@ void set_mode(modes_t mode) {
exe_push(e);
e.function = fc_tagorder;
exe_push(e);
e.function = fc_check_cardinality;
exe_push(e);
break;
}
case mode_baseline: {


BIN
tiffs_should_fail/minimal_different_cardinality_of_stripoffsets_and_stripbytescount.tiff View File


Loading…
Cancel
Save