From 48e22dd008138bb97d2a673af9da5b1b3457c86f Thu Sep 9 08:15:07 2021 From: Sergey Poznyakoff Date: Thu, 9 Sep 2021 15:04:27 +0800 Subject: [PATCH] Fix stack overflow in print_usage src/parseopt.c (print_usage): Fix length calculation for long options. Conflict:NA Reference:https://git.gnu.org.ua/gdbm.git/commit/?id=48e22dd008138bb97d2a673af9da5b1b3457c86f --- src/parseopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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++] = ' ';