From: Paul Eggert Date: Sat, 2 Nov 2024 06:18:30 +0000 (-0700) Subject: Avoid unlikely verbose_option overflow X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6993486ed8f14992cc228021b7e96a7a576e827c;p=thirdparty%2Ftar.git Avoid unlikely verbose_option overflow * src/tar.c (parse_opt, decode_options): Avoid undefined behavior if verbose_option overflows. --- diff --git a/src/tar.c b/src/tar.c index 3a4421e9..66486fcf 100644 --- a/src/tar.c +++ b/src/tar.c @@ -1797,7 +1797,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case 't': set_subcommand_option (LIST_SUBCOMMAND); - verbose_option++; + verbose_option += verbose_option <= 2; break; case TEST_LABEL_OPTION: @@ -1825,7 +1825,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 'v': - verbose_option++; + verbose_option += verbose_option <= 2; warning_option |= WARN_VERBOSE_WARNINGS; break; @@ -2710,7 +2710,7 @@ decode_options (int argc, char **argv) /* --test-label is silent if the user has specified the label name to compare against. */ if (!name_more_files ()) - verbose_option++; + verbose_option += verbose_option <= 2; } else if (utc_option) verbose_option = 2;