]> Savannah Git Hosting - gnulib.git/commitdiff
getopt-gnu: Fix out-of-bounds access (regression 2023-12-11).
authorBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 00:12:20 +0000 (01:12 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 08:35:22 +0000 (09:35 +0100)
* lib/getopt.c (process_long_option): Don't set ambig_set[option_index]
if ambig_set is &ambig_fallback.

ChangeLog
lib/getopt.c

index ba4ef25796fdd8852bfb44e9ee70fe95338c52a1..79e3a3eedcb081299a4788eea6c7cc437b4e956c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-01-17  Bruno Haible  <bruno@clisp.org>
+
+       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  <eggert@cs.ucla.edu>
 
        posixtm: pacify clang 18
index 928306304ec41dd950f4ec77d65e18fa2ac55a91..f66f119ec50ab3eb0f5810f4dec40ce008a3b338 100644 (file)
@@ -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;
                  }
              }