From 98ca332c4a5ac9e5687fb4fe21b350134bc74d1b Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Mon, 15 Jul 2019 08:38:24 -0600 Subject: [PATCH] rxkad: v5der.c format truncation warnings GCC 7 is producing new warnings due to better compile time analysis. With --enable-checking v5der.c is failing with 2 errors due to possible format-truncation in some snprintf calls. The format strings are being used to format a date and time values from a tm structure. The actual warnings/errors are being triggered from arithmetic being performed on the year and month members of the structure. The resulting values should not exceed the format lengths, but the compilers are still flagging the statements. v5der.c is part of the heimdal package that is pulled into the openafs source tree. v5der.c is not compiled directly but is #included in ticket5.c Update ticket5.c to change the severity of the format-truncation diagnostic to a warning if using GCC 7 (or higher). Note: since v5der.c is pulled from an external source (heimdal), any changes to update v5der.c directly would need to be performed upstream. Change-Id: Icda0d86444f505604abe9fa1cc2450d7538be7ef Reviewed-on: https://gerrit.openafs.org/13661 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- CODING | 6 +++++- src/rxkad/ticket5.c | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CODING b/CODING index fe64431579..5d62dbb0b0 100644 --- a/CODING +++ b/CODING @@ -296,4 +296,8 @@ libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types libadmin/test/client.c : all : util_RPCStatsStateGet types ubik/ubikclient.c : strict-protos : ubik_Call volser/vol-dump.c : format : afs_sfsize_t - +rxkad/ticket5.c : format-truncation : inside included file v5der.c in the + function _heim_time2generalizedtime, the + two snprintf calls raise + format-truncation warnings due to the + arithmetic on tm_year and tm_mon fields \ No newline at end of file diff --git a/src/rxkad/ticket5.c b/src/rxkad/ticket5.c index 1a59d4fcd1..8c750d3ce7 100644 --- a/src/rxkad/ticket5.c +++ b/src/rxkad/ticket5.c @@ -80,7 +80,16 @@ #include "v5gen-rewrite.h" #include "v5gen.h" #include "der.h" + +#if defined(IGNORE_SOME_GCC_WARNINGS) && !defined(_clang) && __GNUC__ >= 7 +# pragma GCC diagnostic push +# pragma GCC diagnostic warning "-Wformat-truncation" +#endif #include "v5der.c" +#if defined(IGNORE_SOME_GCC_WARNINGS) && !defined(__clang__) && __GNUC__ >= 7 +# pragma GCC diagnostic pop +#endif + #include "v5gen.c" #define RFC3961_NO_ENUMS