diff options
author | Werner Koch <[email protected]> | 2020-02-10 13:55:53 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-02-10 13:55:53 +0000 |
commit | 47f514fde6e29137d660c19e6eea0b842d2b03f5 (patch) | |
tree | 6bf6a5010a96811b44ffe0daeab09c2c36f6abbf | |
parent | card: Add new OpenPGP card vendor. (diff) | |
download | gnupg-47f514fde6e29137d660c19e6eea0b842d2b03f5.tar.gz gnupg-47f514fde6e29137d660c19e6eea0b842d2b03f5.zip |
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 <[email protected]>
-rw-r--r-- | common/logging.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/logging.c b/common/logging.c index c4eaca411..df55e6827 100644 --- a/common/logging.c +++ b/common/logging.c @@ -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 (); } |