]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix for leak when completing command word with glob pattern that matches multiple...
authorChet Ramey <chet.ramey@case.edu>
Mon, 17 Jul 2023 21:35:59 +0000 (17:35 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 17 Jul 2023 21:35:59 +0000 (17:35 -0400)
CWRU/CWRU.chlog
MANIFEST
bashline.c
lib/sh/unicode.c
variables.c

index 5ad32a9de893354f55568a2c9c844fb1ba85bab1..b9f94951e13cdef4a4ce462d749d405146f7ac58 100644 (file)
@@ -7124,3 +7124,22 @@ jobs.c
          that we use IS_ASYNC to determine whether to give the terminal
          back to the shell's process group.
          From a report by Grisha Levit <grishalevit@gmail.com>
+
+bashline.c
+       - command_word_completion_function: if we have a glob pattern that
+         expands to multiple words, dispose of the list before returning NULL.
+         From a report by Grisha Levit <grishalevit@gmail.com>
+
+variables.c
+       - makunbound: if we're unsetting a local variable, preserve the export
+         attribute even if the variable's not in the temporary environment
+         Tentative fix, compatible with other POSIX shells (except the BSD
+         variants of ash)
+
+                                  7/12
+                                  ----
+lib/sh/unicode.c
+       - include <langinfo.h> if HAVE_LANGINFO_CODESET is defined, use
+         nl_langinfo (CODESET) if HAVE_LANGINFO_CODESET is define, since
+         we no longer check for nl_langinfo. This is what locale.c does.
+
index 36ef4d413236fc77a7338c75d646da0276f06b56..2643645ddb7dfb0e4699a55864fc5bee11efaae2 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -973,7 +973,7 @@ tests/assoc16.sub   f
 tests/assoc17.sub      f
 tests/assoc18.sub      f
 tests/assoc19.sub      f
-`tests/attr.tests      f
+tests/attr.tests       f
 tests/attr.right       f
 tests/attr1.sub                f
 tests/attr2.sub                f
index 0e5373ab43faca0fc5371645eb49aa52d8e0e6b6..2fb00e82c53127aedeaaf91e76099ce97b88f08f 100644 (file)
@@ -2192,7 +2192,11 @@ globword:
          local_index = 0;
                
          if (glob_matches[1] && rl_completion_type == TAB)     /* multiple matches are bad */
-           return ((char *)NULL);
+           {
+             strvec_dispose (glob_matches);
+             glob_matches = (char **)NULL;
+             return ((char *)NULL);
+           }
        }
 
       while (val = glob_matches[local_index++])
index 24d3d50d640a12f0f36b16f38e4cae64ccfbf0b0..87bb5c803c5e01d873a3f8f75f84c855bd4a8106 100644 (file)
 #  include <iconv.h>
 #endif
 
+#if HAVE_LANGINFO_CODESET
+#  include <langinfo.h>
+#endif
+
 #include <xmalloc.h>
 
 #ifndef USHORT_MAX
@@ -267,7 +271,7 @@ u32cconv (unsigned long c, char *s)
        {
 #if HAVE_LOCALE_CHARSET
          charset = locale_charset ();
-#elif HAVE_NL_LANGINFO
+#elif HAVE_LANGINFO_CODESET
          charset = nl_langinfo (CODESET);
 #else
          charset = stub_charset ();
index 05a0daa00555de9cabac9a9f33957f135d559517..854d39f8a24b286e4726a2f87544e4ff2c0a27cc 100644 (file)
@@ -3942,10 +3942,16 @@ makunbound (const char *name, VAR_CONTEXT *vc)
        FREE (nameref_cell (old_var));
       else
        FREE (value_cell (old_var));
+#if 0
       /* Reset the attributes.  Preserve the export attribute if the variable
         came from a temporary environment.  Make sure it stays local, and
         make it invisible. */ 
       old_var->attributes = (exported_p (old_var) && tempvar_p (old_var)) ? att_exported : 0;
+#else  /* TAG:bash-5.3 look at this again */
+      /* Reset the attributes, but preserve the export attribute.
+        Make sure it stays local, and make it invisible. */ 
+      old_var->attributes = exported_p (old_var) ? att_exported : 0;
+#endif
       VSETATTR (old_var, att_local);
       VSETATTR (old_var, att_invisible);
       var_setvalue (old_var, (char *)NULL);