From 675f7fc6d69c483c83b19777a8ef39f60eed05b7 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 3b86638ea3..63101e5f20 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-17 Bruno Haible Improve naming of local variables. 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