From c78af17a931bb36e00c5f698b7fd37deb4a87f58 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 18 Jan 2024 01:12:20 +0100 Subject: [PATCH] getopt-gnu: Fix out-of-bounds access (regression 2023-12-11). * lib/getopt.c (process_long_option): Don't set ambig_set[option_index] if ambig_set is &ambig_fallback. --- ChangeLog | 6 ++++++ lib/getopt.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ba4ef25796..79e3a3eedc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-01-17 Bruno Haible + + getopt-gnu: Fix out-of-bounds access (regression 2023-12-11). + * lib/getopt.c (process_long_option): Don't set ambig_set[option_index] + if ambig_set is &ambig_fallback. + 2024-01-16 Paul Eggert posixtm: pacify clang 18 diff --git a/lib/getopt.c b/lib/getopt.c index 928306304e..f66f119ec5 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -268,7 +268,7 @@ process_long_option (int argc, char **argv, const char *optstring, ambig_set[indfound] = 1; } } - if (ambig_set) + if (ambig_set && ambig_set != &ambig_fallback) ambig_set[option_index] = 1; } } -- 2.39.5