]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20140425 snapshot
authorChet Ramey <chet.ramey@case.edu>
Wed, 30 Apr 2014 20:54:12 +0000 (16:54 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 30 Apr 2014 20:54:12 +0000 (16:54 -0400)
16 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
array.c
assoc.c
bashline.c
builtins/complete.def
config-top.h
jobs.c
lib/intl/l10nflist.c
patchlevel.h
redir.c
shell.c
subst.c
subst.c~
tests/RUN-ONE-TEST
trap.c

index 3e94bd4d570cec5af690be70aa6347487b532b71..674ec46cb9020a4415a466aaebb024cb0831ff94 100644 (file)
@@ -6149,3 +6149,47 @@ builtins/hash.def
        - print_portable_hash_info: single-quote pathnames and hashed filenames
          that contain shell metacharacters.  Fixes bug reported by
          <g1pi@libero.it> in debian bash bug #739853
+
+                                  4/23
+                                  ----
+{bashhist,bashline}.c
+builtins{bind,help,type}.def
+lib/glob/glob.c, lib/intl/{loadmsgcat,localealias}.c,lib/sh/mktime.c
+       - fixes to memory leaks uncovered by coverity scan
+
+                                  4/24
+                                  ----
+{bashhist,subst,redir,assoc,jobs,array,trap}.c
+lib/intl/l10flist.c
+builtins/complete.def
+       - fixes to memory leaks and other resource usage problems uncovered by
+         coverity scan
+
+redir.c
+       - do_redirection_internal: if dup2 fails (presumably because of a
+         resource limit), close the file descriptor we opened before returning
+         error
+
+                                  4/25
+                                  ----
+config-top.h
+       - DEFAULT_BASHRC: new define with the name of the default shell
+         startup file
+
+bashline.c
+       - bash_directory_completion_matches: don't dequote the directory name.
+         If rl_completion_found_quote is non-zero, readline will dequote the
+         filename itself.  Fixes bug reported by Clark Wang
+         <dearvoid@gmail.com>
+
+                                  4/27
+                                  ----
+subst.c
+       - parameter_brace_expand_indir: if parameter_brace_find_indir returns
+         NULL or "", report an error and return &expand_param_error so the
+         error can propagate up
+       - parameter_brace_expand_rhs: if parameter_brace_find_indir returns
+         NULL or "", or if it returns something that is not a valid identifier,
+         report an error and return &expand_wdesc_error so the error can
+         propagate up.  Fixes bug reported by Andre Holzhey
+         <andre.holzhey@gmx.de>
index 6053a97b25c99edaf5b818f824a75a0bd214a766..19d3ef3d0fd99be1c48e73e04cf2ce0a15574474 100644 (file)
@@ -6144,3 +6144,40 @@ subst.c
          arguments separated by spaces and don't do word splitting.  Fixes
          bug reported by Greg Wooledge <wooledg@eeg.ccf.org> from an IRC
          discussion
+
+builtins/hash.def
+       - print_portable_hash_info: single-quote pathnames and hashed filenames
+         that contain shell metacharacters.  Fixes bug reported by
+         <g1pi@libero.it> in debian bash bug #739853
+
+                                  4/23
+                                  ----
+{bashhist,bashline}.c
+builtins{bind,help,type}.def
+lib/glob/glob.c, lib/intl/{loadmsgcat,localealias}.c,lib/sh/mktime.c
+       - fixes to memory leaks uncovered by coverity scan
+
+                                  4/24
+                                  ----
+{bashhist,subst,redir,assoc,jobs,array,trap}.c
+lib/intl/l10flist.c
+builtins/complete.def
+       - fixes to memory leaks and other resource usage problems uncovered by
+         coverity scan
+
+redir.c
+       - do_redirection_internal: if dup2 fails (presumably because of a
+         resource limit), close the file descriptor we opened before returning
+         error
+
+                                  4/25
+                                  ----
+config-top.h
+       - DEFAULT_BASHRC: new define with the name of the default shell
+         startup file
+
+bashline.c
+       - bash_directory_completion_matches: don't dequote the directory name.
+         If rl_completion_found_quote is non-zero, readline will dequote the
+         filename itself.  Fixes bug reported by Clark Wang
+         <dearvoid@gmail.com>
diff --git a/array.c b/array.c
index 4359a52fa1d88e4d52fcff439092bb89950e9084..bf31acd072be2617226e31f496e0c6669c655c5b 100644 (file)
--- a/array.c
+++ b/array.c
@@ -834,7 +834,7 @@ int quoted;
                                                rsize, rsize);
                        strcpy(result + rlen, t);
                        rlen += reg;
-                       if (quoted && t)
+                       if (quoted)
                                free(t);
                        /*
                         * Add a separator only after non-null elements.
diff --git a/assoc.c b/assoc.c
index f9ed8816e305fe71b829dfef874d997319b41d1b..5499043717ab9cb2f6a538f78422e2fcacc4b40c 100644 (file)
--- a/assoc.c
+++ b/assoc.c
@@ -277,7 +277,10 @@ int starsub, quoted;
   for (i = 1; l && i < start; i++)
     l = l->next;
   if (l == 0)
-    return ((char *)NULL);
+    {
+      dispose_words (save);
+      return ((char *)NULL);
+    }
   for (j = 0,h = t = l; l && j < nelem; j++)
     {
       t = l;
index 446a98baedd54aa197bee4f52de14e88369a2a50..238a190c528d61a340fa9ae7ca0073ce67bbfc4c 100644 (file)
@@ -4208,9 +4208,16 @@ bash_directory_completion_matches (text)
   int qc;
 
   qc = rl_dispatching ? rl_completion_quote_character : 0;  
-  dfn = bash_dequote_filename ((char *)text, qc);
+  /* If rl_completion_found_quote != 0, rl_completion_matches will call the
+     filename dequoting function, causing the directory name to be dequoted
+     twice. */
+  if (rl_dispatching && rl_completion_found_quote == 0)
+    dfn = bash_dequote_filename ((char *)text, qc);
+  else
+    dfn = (char *)text;
   m1 = rl_completion_matches (dfn, rl_filename_completion_function);
-  free (dfn);
+  if (dfn != text)
+    free (dfn);
 
   if (m1 == 0 || m1[0] == 0)
     return m1;
index 8499b7a6e408423d55d1f58b0c53115b17ee0cf5..0a97dfb3f9054d3ab3d880ba2586f2f382bcdb3e 100644 (file)
@@ -867,5 +867,8 @@ compopt_builtin (list)
       pcomp_set_compspec_options (cs, opts_off, 0);
     }
 
+  if (wl)
+    dispose_words (wl);
+
   return (ret);
 }
index 4f6373c4ab875c2879725d8fba97ba82a1cf1d8e..7ef5fbad24ae9c77d12d306d4311d3888497f685 100644 (file)
@@ -79,6 +79,9 @@
    reply to the select query is an empty line. */
 #define KSH_COMPATIBLE_SELECT
 
+/* Default interactive shell startup file. */
+#define DEFAULT_BASHRC "~/.bashrc"
+
 /* System-wide .bashrc file for interactive shells. */
 /* #define SYS_BASHRC "/etc/bash.bashrc" */
 
diff --git a/jobs.c b/jobs.c
index f38b0c3f4446fc48cf2dc314f35c94f5c749b705..cecf9d11906457811c4fb3c39fb029e63945edda 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -3818,7 +3818,8 @@ initialize_job_control (force)
        {
          shell_pgrp = getpid ();
          setpgid (0, shell_pgrp);
-         tcsetpgrp (shell_tty, shell_pgrp);
+         if (shell_tty != -1)
+           tcsetpgrp (shell_tty, shell_pgrp);
        }
 
       while ((terminal_pgrp = tcgetpgrp (shell_tty)) != -1)
index 7556c8cd7b23a3a38d2c709d5aa51fb4f9c74dc3..4ce284a2b9aa10862fd33d9aba4a2c7961c2850b 100644 (file)
@@ -332,7 +332,10 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
            + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
               * sizeof (struct loaded_l10nfile *)));
   if (retval == NULL)
-    return NULL;
+    {
+      free (abs_filename);
+      return NULL;
+    }
 
   retval->filename = abs_filename;
 
index d3516b22686cff9fc8fd1d270c809bb9324a902e..b7c2ff4c16724999ddcedec12ca853f412f67e0e 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 0
+#define PATCHLEVEL 11
 
 #endif /* _PATCHLEVEL_H_ */
diff --git a/redir.c b/redir.c
index a4a3bb7e213b7e8886f6c59b51580c04a73189c3..a0b7f24e68460a7fe095b003ef34feb31575fff1 100644 (file)
--- a/redir.c
+++ b/redir.c
@@ -410,8 +410,11 @@ write_here_document (fd, redirectee)
         may need to be reconsidered later. */
       if ((fd2 = dup (fd)) < 0 || (fp = fdopen (fd2, "w")) == NULL)
        {
+         old = errno;
          if (fd2 >= 0)
            close (fd2);
+         dispose_words (tlist);
+         errno = old;
          return (errno);
        }
       errno = 0;
@@ -902,7 +905,10 @@ do_redirection_internal (redirect, flags)
                }
            }
          else if ((fd != redirector) && (dup2 (fd, redirector) < 0))
-           return (errno);
+           {
+             close (fd);       /* dup2 failed? must be fd limit issue */
+             return (errno);
+           }
 
 #if defined (BUFFERED_INPUT)
          /* Do not change the buffered stream for an implicit redirection
diff --git a/shell.c b/shell.c
index ff7734dba2af5365df5f9b742098b9be861e8146..e2fb526dec61c778f22a5a867e03afa1933090ef 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -191,7 +191,7 @@ int have_devfd = 0;
 #endif
 
 /* The name of the .(shell)rc file. */
-static char *bashrc_file = "~/.bashrc";
+static char *bashrc_file = DEFAULT_BASHRC;
 
 /* Non-zero means to act more like the Bourne shell on startup. */
 static int act_like_sh;
@@ -1801,7 +1801,7 @@ shell_reinitialize ()
 
   /* Ensure that the default startup file is used.  (Except that we don't
      execute this file for reinitialized shells). */
-  bashrc_file = "~/.bashrc";
+  bashrc_file = DEFAULT_BASHRC;
 
   /* Delete all variables and functions.  They will be reinitialized when
      the environment is parsed. */
diff --git a/subst.c b/subst.c
index f94d12927147cc2c6ba8e6ece1a7c242e93af4bc..ca9bfef117e97c7a248f656cef703c013093b4f0 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3024,7 +3024,10 @@ pos_params (string, start, end, quoted)
   for (i = start ? 1 : 0; params && i < start; i++)
     params = params->next;
   if (params == 0)
-    return ((char *)NULL);
+    {
+      dispose_words (save);
+      return ((char *)NULL);
+    }
   for (h = t = params; params && i < end; i++)
     {
       t = params;
@@ -5915,6 +5918,14 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c
     }
 
   t = parameter_brace_find_indir (name, var_is_special, quoted, 0);
+  if (t == 0 || *t == 0)
+    {
+      report_error (_("%s: invalid indirect expansion"), name);
+      w = alloc_word_desc ();
+      w->word = &expand_param_error;
+      w->flags = 0;
+      return w;
+    }
 
   chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at);
   if (t == 0)
@@ -5937,7 +5948,7 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
 {
   WORD_DESC *w;
   WORD_LIST *l;
-  char *t, *t1, *temp;
+  char *t, *t1, *temp, *vname;
   int hasdol;
 
   /* If the entire expression is between double quotes, we want to treat
@@ -6008,16 +6019,42 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
   t = temp ? savestring (temp) : savestring ("");
   t1 = dequote_string (t);
   free (t);
+
+  /* bash-4.4/5.0 */
+  vname = name;
+  if (*name == '!' &&
+      (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1]) || VALID_INDIR_PARAM (name[1])))
+    {
+      vname = parameter_brace_find_indir (name + 1, SPECIAL_VAR (name, 1), quoted, 1);
+      if (vname == 0 || *vname == 0)
+       {
+         report_error (_("%s: invalid indirect expansion"), name);
+         free (vname);
+         dispose_word (w);
+         return &expand_wdesc_error;
+       }
+      if (legal_identifier (vname) == 0)
+       {
+         report_error (_("%s: invalid variable name"), vname);
+         free (vname);
+         dispose_word (w);
+         return &expand_wdesc_error;
+       }
+    }
+    
 #if defined (ARRAY_VARS)
-  if (valid_array_reference (name))
-    assign_array_element (name, t1, 0);
+  if (valid_array_reference (vname))
+    assign_array_element (vname, t1, 0);
   else
 #endif /* ARRAY_VARS */
-  bind_variable (name, t1, 0);
+  bind_variable (vname, t1, 0);
 #if 0
-  if (STREQ (name, "IFS") == 0)
+  if (STREQ (vname, "IFS") == 0)
 #endif
-    stupidly_hack_special_variables (name);
+    stupidly_hack_special_variables (vname);
+
+  if (vname != name)
+    free (vname);
 
   /* From Posix group discussion Feb-March 2010.  Issue 7 0000221 */
   free (temp);
@@ -6381,6 +6418,7 @@ get_var_and_type (varname, value, ind, quoted, flags, varp, valp)
                                        || VALID_INDIR_PARAM (varname[1]));
   if (want_indir)
     vname = parameter_brace_find_indir (varname+1, SPECIAL_VAR (varname, 1), quoted, 1);
+    /* XXX - what if vname == 0 || *vname == 0 ? */
   else
     vname = varname;
     
index 564e9f51bbbf5b9ebb395b71a8bdfd7b8bc4ca54..86722d2bcf08b5354ac9de1396ae74d06f89eac8 100644 (file)
--- a/subst.c~
+++ b/subst.c~
@@ -3024,7 +3024,10 @@ pos_params (string, start, end, quoted)
   for (i = start ? 1 : 0; params && i < start; i++)
     params = params->next;
   if (params == 0)
-    return ((char *)NULL);
+    {
+      dispose_words (save);
+      return ((char *)NULL);
+    }
   for (h = t = params; params && i < end; i++)
     {
       t = params;
@@ -5736,7 +5739,7 @@ parameter_brace_expand_word (name, var_is_special, quoted, pflags, indp)
   char *temp, *tt;
   intmax_t arg_index;
   SHELL_VAR *var;
-  int atype, rflags, contains_dollar_at, quoted_dollar_at;
+  int atype, rflags;
   arrayind_t ind;
 
   ret = 0;
@@ -5765,8 +5768,8 @@ parameter_brace_expand_word (name, var_is_special, quoted, pflags, indp)
       tt[sindex = 0] = '$';
       strcpy (tt + 1, name);
 
-      ret = param_expand (tt, &sindex, quoted, (int *)NULL, &contains_dollar_at,
-                         &quoted_dollar_at, (int *)NULL, pflags);
+      ret = param_expand (tt, &sindex, quoted, (int *)NULL, (int *)NULL,
+                         (int *)NULL, (int *)NULL, pflags);
       free (tt);
     }
 #if defined (ARRAY_VARS)
@@ -5915,6 +5918,14 @@ parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, c
     }
 
   t = parameter_brace_find_indir (name, var_is_special, quoted, 0);
+  if (t == 0 || *t == 0)
+    {
+      report_error (_("%s: invalid indirect expansion"), name);
+      w = alloc_word_desc ();
+      w->word = &expand_param_error;
+      w->flags = 0;
+      return w;
+    }
 
   chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at);
   if (t == 0)
@@ -5937,7 +5948,7 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
 {
   WORD_DESC *w;
   WORD_LIST *l;
-  char *t, *t1, *temp;
+  char *t, *t1, *temp, *vname;
   int hasdol;
 
   /* If the entire expression is between double quotes, we want to treat
@@ -6008,16 +6019,42 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
   t = temp ? savestring (temp) : savestring ("");
   t1 = dequote_string (t);
   free (t);
+
+  /* bash-4.4/5.0 */
+  vname = name;
+  if (*name == '!' &&
+      (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1]) || VALID_INDIR_PARAM (name[1])))
+    {
+      vname = parameter_brace_find_indir (name + 1, SPECIAL_VAR (name, 1), quoted, 1);
+      if (vname == 0 || *vname == 0)
+       {
+         report_error (_("%s: invalid indirect expansion"), name);
+         free (vname);
+         dispose_word (w);
+         return &expand_wdesc_error;
+       }
+      if (legal_identifier (vname) == 0)
+       {
+         report_error (_("%s: invalid variable name"), vname);
+         free (vname);
+         dispose_word (w);
+         return &expand_wdesc_error;
+       }
+    }
+    
 #if defined (ARRAY_VARS)
-  if (valid_array_reference (name))
-    assign_array_element (name, t1, 0);
+  if (valid_array_reference (vname))
+    assign_array_element (vname, t1, 0);
   else
 #endif /* ARRAY_VARS */
-  bind_variable (name, t1, 0);
+  bind_variable (vname, t1, 0);
 #if 0
-  if (STREQ (name, "IFS") == 0)
+  if (STREQ (vname, "IFS") == 0)
 #endif
-    stupidly_hack_special_variables (name);
+    stupidly_hack_special_variables (vname);
+
+  if (vname != name)
+    free (vname);
 
   /* From Posix group discussion Feb-March 2010.  Issue 7 0000221 */
   free (temp);
index 72ec06a2c1fd8dde92acea5e8ac773e35f1d061b..3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04 100755 (executable)
@@ -1,4 +1,4 @@
-BUILD_DIR=/usr/local/build/bash/bash-current
+BUILD_DIR=/usr/local/build/chet/bash/bash-current
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR
 
diff --git a/trap.c b/trap.c
index 2766e64b30f5cf29b6d49d8e6c3c36da879aaa36..a661706a2a15b65000b109bf4cd4ee14cfbf27d3 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -858,6 +858,8 @@ run_exit_trap ()
        retval = trap_saved_exit_value;
 
       running_trap = 0;
+      array_dispose (ps);
+
       return retval;
     }