aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-09-09 08:15:07 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-09-09 08:15:07 +0300
commit48e22dd008138bb97d2a673af9da5b1b3457c86f (patch)
treec55df59f875f66512e454cf44c5da4ac29a94dda
parentf586b159887740c2781dfe2bdd89331083742033 (diff)
downloadgdbm-48e22dd008138bb97d2a673af9da5b1b3457c86f.tar.gz
gdbm-48e22dd008138bb97d2a673af9da5b1b3457c86f.tar.bz2
Fix stack overflow in print_usage
* src/parseopt.c (print_usage): Fix length calculation for long options.
-rw-r--r--src/parseopt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/parseopt.c b/src/parseopt.c
index bc47597..efa12c8 100644
--- a/src/parseopt.c
+++ b/src/parseopt.c
@@ -495,7 +495,7 @@ print_usage (void)
{
struct gdbm_option *opt = option_tab + idxbuf[i];
const char *arg = opt->opt_arg ? gettext (opt->opt_arg) : NULL;
- size_t len = 3 + strlen (opt->opt_long)
+ size_t len = 5 + strlen (opt->opt_long)
+ (arg ? 1 + strlen (arg) : 0);
if (n + len > RMARGIN) FLUSH;
buf[n++] = ' ';

Return to:

Send suggestions and report system problems to the System administrator.