1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

common: Also protect log_inc_errorcount against counter overflow.

* common/logging.c (log_inc_errorcount): Also protect against
overflow.
(log_error): Call log_inc_errorcount instead of directly bumping the
counter.
--

We already had an overflow checking for log_error but not for the
silent increment function.

This is basically the same fix we have in libgpg-error
(libgpg-error commit d72c1ddfde09ffa69745ec2439c5a16d15e2202f)

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-02-10 14:55:53 +01:00
parent c1d716cd65
commit 47f514fde6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -129,7 +129,9 @@ log_get_errorcount (int clear)
void
log_inc_errorcount (void)
{
errorcount++;
/* Protect against counter overflow. */
if (errorcount < 30000)
errorcount++;
}
@ -932,9 +934,7 @@ log_error (const char *fmt, ...)
va_start (arg_ptr, fmt);
do_logv (GPGRT_LOG_ERROR, 0, NULL, NULL, fmt, arg_ptr);
va_end (arg_ptr);
/* Protect against counter overflow. */
if (errorcount < 30000)
errorcount++;
log_inc_errorcount ();
}