aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-03-03 11:23:59 +0000
committerWerner Koch <[email protected]>2020-03-03 11:23:59 +0000
commitc8ad567e7c87987581e702b9c7c0f5310e72d996 (patch)
tree847b6699706c8d1026903204d7b53db1c35da9e5
parentPost release updates (diff)
downloadgnupg-c8ad567e7c87987581e702b9c7c0f5310e72d996.tar.gz
gnupg-c8ad567e7c87987581e702b9c7c0f5310e72d996.zip
Protect error counter against overflow.
* util/logger.c (log_inc_errorcount): Protect against overflow. (g10_log_warning): Bumb error counter using the above function. (g10_log_error): Ditto. -- This is a similar patch we use in 2.2 and libgpg-error. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--util/logger.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/util/logger.c b/util/logger.c
index d63161196..7e488b02b 100644
--- a/util/logger.c
+++ b/util/logger.c
@@ -109,6 +109,8 @@ log_get_errorcount( int clear)
void
log_inc_errorcount()
{
+ /* Protect agains overflow. */
+ if (errorcount < 30000)
errorcount++;
}
@@ -135,7 +137,7 @@ g10_log_print_prefix(const char *text)
if (!logfp )
{
FILE *ttyfp_local;
-
+
init_ttyfp();
ttyfp_local = ttyfp_is ();
if (isatty (fileno (stderr)) && isatty (fileno (ttyfp_local)))
@@ -179,7 +181,7 @@ g10_log_warning( const char *fmt, ... )
if(strict)
{
- errorcount++;
+ log_inc_errorcount ();
g10_log_print_prefix(_("ERROR: "));
}
else
@@ -203,7 +205,7 @@ g10_log_error( const char *fmt, ... )
va_start( arg_ptr, fmt ) ;
vfprintf(logfp,fmt,arg_ptr) ;
va_end(arg_ptr);
- errorcount++;
+ log_inc_errorcount ();
#ifdef __riscos__
fflush( logfp );
#endif /* __riscos__ */
@@ -285,6 +287,3 @@ g10_log_hexdump( const char *text, const char *buf, size_t len )
fflush( logfp );
#endif /* __riscos__ */
}
-
-
-