Browse Source

- fixed gcc format-truncation-warnings

development
Andreas Romeyke 8 months ago
parent
commit
c8b2bb534c
  1. 6
      src/parser/config_parser.c
  2. 20
      src/validate_icc/check_icc_header.c

6
src/parser/config_parser.c

@ -1361,15 +1361,15 @@ ret_t print_plan_results(retmsg_t * actual_render) {
harderrors:
{
int errors = (parser_state.result_stackp -count_of_valid_results );
char msg[20];
snprintf(msg, 20, "Found %i errors", errors) ;
char msg[25];
snprintf(msg, 25, "Found %i errors", errors) ;
if (errors > 0) {
res.returncode = is_error;
__add_to_render_pipeline_via_strncpy(&actual_render, STRING_AND_LEN(msg), rm_error);
__add_to_render_pipeline_via_strncpy(&actual_render, STRING_AND_LEN("No, the given tif is not valid :("), rm_summary_invalid);
} else {
res.returncode = is_valid;
__add_to_render_pipeline_via_strncpy(&actual_render, msg, 19, rm_is_valid);
__add_to_render_pipeline_via_strncpy(&actual_render, msg, 24, rm_is_valid);
__add_to_render_pipeline_via_strncpy(&actual_render, STRING_AND_LEN("Yes, the given tif is valid :)"), rm_summary_valid);
}
}

20
src/validate_icc/check_icc_header.c

@ -1,6 +1,6 @@
/* checks ICC Profile, using Spec http://www.color.org/specification/ICC1v43_2010-12.pdf */
#include "validate_icc.h"
/*
/*
#define USE_WARNING
#ifdef USE_WARNING
#define FAIL(...) {fprintf(stderr, __VA_ARGS__); return 1;};
@ -66,7 +66,9 @@ icc_returncode_t parse_icc_common_header(unsigned long iccsize, char * iccdata,
) FAIL(icc_error_preferredcmmtype, "preferred cmmtype ('%s') should be empty or (possibly, because ICC validation is alpha code) one of following strings: 'ADBE' 'ACMS' 'appl' 'CCMS' 'UCCM' 'UCMS' 'EFI ' 'FF ' 'EXAC' 'HCMM' 'argl' 'LgoS' 'HDM ' 'lcms' 'KCMS' 'MCML' 'WCS ' 'SIGN' 'RGMS' 'SICC' 'TCMM' '32BT' 'WTG ' 'zc00'", preferredcmmtype);
/* -- */
char profileversion[6]=" "; snprintf(profileversion, 6, "%i.%i.%i", (iccdata[8]) & 0x000f, ((iccdata[9] & 0x00f0) >>4), (iccdata[9] & 0x000f));
char profileversion[6]=" ";
int snprintf_error = snprintf(profileversion, 6, "%i.%i.%i", (iccdata[8]) & 0x000f, ((iccdata[9] & 0x00f0) >>4), (iccdata[9] & 0x000f));
if (snprintf_error != 5) { FAIL(icc_error_header_version_undefined, "invalid profile version %s", profileversion) };
INFO("ICC: profileversion='%s'\n", profileversion);
// TODO: 2.4.0 or 4.3.0, others not allowed?
/* -- */
@ -120,7 +122,7 @@ icc_returncode_t parse_icc_common_header(unsigned long iccsize, char * iccdata,
) FAIL(icc_error_connectionspacedata, "connection space data ('%s') should be one of following strings: 'XYZ ' 'Lab '", connectionspacedata);
/* -- */
// datetime 24-35
char datetime[20]; snprintf(datetime, 20, "%.4d:%.2d:%.2d %.2d:%.2d:%.2d",
char datetime[37]; snprintf(datetime, 37, "%.4d:%.2d:%.2d %.2d:%.2d:%.2d",
((iccdata[24] & 0x00ff)<<8 | (iccdata[25] & 0x00ff)), // yyyy
((iccdata[26] & 0x00ff)<<8 | (iccdata[27] & 0x00ff)), // MM
((iccdata[28] & 0x00ff)<<8 | (iccdata[29] & 0x00ff)), // DD
@ -245,11 +247,13 @@ icc_returncode_t parse_icc(unsigned long iccsize, char* iccdata, unsigned long e
unsigned short b = (unsigned short) ((iccdata[9] & 0x00f0) >> 4);
unsigned short c = (unsigned short) (iccdata[9] & 0x000f);
char profileversion[6]=" ";
snprintf(profileversion, 6, "%1i.%1i.%1i", a, b, c);
INFO("ICC: profileversion='%s'\n", profileversion);
if (0==strncmp(profileversion, "5.0.0", 5)) return parse_icc_v500(iccsize, iccdata, errsize, errmessage);
if (0==strncmp(profileversion, "4.3.0", 5)) return parse_icc_v430(iccsize, iccdata, errsize, errmessage);
if (0==strncmp(profileversion, "2.4.0", 5)) return parse_icc_v240(iccsize,iccdata, errsize, errmessage);
int snprintf_error = snprintf(profileversion, 6, "%hi.%hi.%hi", a, b, c);
if (snprintf_error == 5) {
INFO("ICC: profileversion='%s'\n", profileversion);
if (0==strncmp(profileversion, "5.0.0", 5)) return parse_icc_v500(iccsize, iccdata, errsize, errmessage);
if (0==strncmp(profileversion, "4.3.0", 5)) return parse_icc_v430(iccsize, iccdata, errsize, errmessage);
if (0==strncmp(profileversion, "2.4.0", 5)) return parse_icc_v240(iccsize,iccdata, errsize, errmessage);
}
FAIL (icc_error_header_version_outdated, "ICC: profileversion='%s' is outdated or wrong", profileversion);
return icc_should_not_occur;
}

Loading…
Cancel
Save