1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-03 12:11:33 +01:00

gpg: Fix format string issues in tofu.

* g10/tofu.c (write_stats_status): Use ulong for MESSSAGES.  Fix
format strings.  Simplify by using the new write_status_printf.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-09-07 08:41:48 +02:00
parent c894fa8d37
commit 97a67d42dc
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -2411,11 +2411,12 @@ write_stats_status (estream_t fp,
unsigned long encryption_most_recent) unsigned long encryption_most_recent)
{ {
const char *validity; const char *validity;
unsigned long messages;
/* Use the euclidean distance rather then the sum of the magnitudes /* Use the euclidean distance rather then the sum of the magnitudes
to ensure a balance between verified signatures and encrypted to ensure a balance between verified signatures and encrypted
messages. */ messages. */
float messages = sqrtu32 (signature_count) + sqrtu32 (encryption_count); messages = sqrtu32 (signature_count) + sqrtu32 (encryption_count);
if (messages < 1) if (messages < 1)
validity = "1"; /* Key without history. */ validity = "1"; /* Key without history. */
@ -2428,7 +2429,7 @@ write_stats_status (estream_t fp,
if (fp) if (fp)
{ {
es_fprintf (fp, "tfs:1:%s:%ld:%ld:%s:%lu:%lu:%lu:%lu:\n", es_fprintf (fp, "tfs:1:%s:%lu:%lu:%s:%lu:%lu:%lu:%lu:\n",
validity, signature_count, encryption_count, validity, signature_count, encryption_count,
tofu_policy_str (policy), tofu_policy_str (policy),
signature_first_seen, signature_most_recent, signature_first_seen, signature_most_recent,
@ -2436,25 +2437,16 @@ write_stats_status (estream_t fp,
} }
else else
{ {
char numbuf1[35]; write_status_printf (STATUS_TOFU_STATS,
char numbuf2[35]; "%s %lu %lu %s %lu %lu %lu %lu",
char numbuf3[35]; validity,
char numbuf4[35]; signature_count,
char numbuf5[35]; encryption_count,
char numbuf6[35]; tofu_policy_str (policy),
signature_first_seen,
snprintf (numbuf1, sizeof numbuf1, " %ld", signature_count); signature_most_recent,
snprintf (numbuf2, sizeof numbuf2, " %ld", encryption_count); encryption_first_done,
snprintf (numbuf3, sizeof numbuf3, " %lu", signature_first_seen); encryption_most_recent);
snprintf (numbuf4, sizeof numbuf4, " %lu", signature_most_recent);
snprintf (numbuf5, sizeof numbuf5, " %lu", encryption_first_done);
snprintf (numbuf6, sizeof numbuf6, " %lu", encryption_most_recent);
write_status_strings (STATUS_TOFU_STATS,
validity, numbuf1, numbuf2,
" ", tofu_policy_str (policy),
numbuf3, numbuf4, numbuf5, numbuf6,
NULL);
} }
} }