]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix for multiple assignment statements containing nofork comsubs preceding a command...
authorChet Ramey <chet.ramey@case.edu>
Mon, 31 Mar 2025 13:58:59 +0000 (09:58 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 31 Mar 2025 13:58:59 +0000 (09:58 -0400)
14 files changed:
CHANGES
CHANGES-5.3
CWRU/CWRU.chlog
general.h
hashlib.c
hashlib.h
po/hr.gmo
po/hr.po
shell.c
subst.c
tests/RUN-ONE-TEST
tests/builtins.right
variables.c
variables.h

diff --git a/CHANGES b/CHANGES
index a264b4d2c08ebb224d0d197af9ce8287db9a4ebb..caf1f1a61ee5064ecfe48da5d0983440e488a83f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -35,11 +35,17 @@ j. Fixed a bug in command printing that output the wrong default file
 
 k. User-specified subshells (`(...)') now update BASH_COMMAND in the subshell.
 
-l. Fixed a bug with the `help -m' and loadable builtins.
+l. Fixed a display bug with the `help -m' and loadable builtins.
 
 m. Fixed a potential file descriptor leak when trying to use a pipe for a
    here document.
 
+n. Fix a bug with multiple assignment statements preceding a simple command
+   containing nofork comsubs.
+
+o. Fix a potential bug that could result in a NULL buffered stream even with
+   a valid input file descriptor.
+
 2. Changes to Readline
 
 a. Fixed a bug that allowed a history search to change the current history
index c34dfb8a90ee84bcc64160e1197ff8c60d5a7754..2eb4b56b3d68502298f589213282e076230571b2 100644 (file)
@@ -35,11 +35,17 @@ j. Fixed a bug in command printing that output the wrong default file
 
 k. User-specified subshells (`(...)') now update BASH_COMMAND in the subshell.
 
-l. Fixed a bug with the `help -m' and loadable builtins.
+l. Fixed a display bug with the `help -m' and loadable builtins.
 
 m. Fixed a potential file descriptor leak when trying to use a pipe for a
    here document.
 
+n. Fix a bug with multiple assignment statements preceding a simple command
+   containing nofork comsubs.
+
+o. Fix a potential bug that could result in a NULL buffered stream even with
+   a valid input file descriptor.
+
 2. Changes to Readline
 
 a. Fixed a bug that allowed a history search to change the current history
index 9a15f86ba216fcdbe23654cd96bf669ac5cc379f..b0894740ea4114a80c38b62ca9877602abc6a520 100644 (file)
@@ -11080,3 +11080,19 @@ configure.ac
                                   ----
 lib/readline/rlmbutil.h
        - _rl_wcwidth: make sure wchar_t constants have an `L' prefix
+
+                                  3/24
+                                  ----
+subst.c
+       - function_substitute: set temporary_env to NULL (we've already
+         set up an unwind-protect for it) before pushing the context, so
+         pop_context doesn't free it out from underneath the caller.
+         Report from Emanuele Torre <torreemanuele6@gmail.com>
+
+                                  3/27
+                                  ----
+shell.c
+       - set_bash_input: if the call to with_input_from_buffered_stream does
+         not result in a valid buffer corresponding to the file descriptor,
+         print an error message and set last_command_exit_value
+         From a report in https://savannah.gnu.org/patch/?10512
index 0528bbf1d84f2fdb050e8850d5dde5a183d60e19..c73758c28271ce731ad39f861c18578408af9b00 100644 (file)
--- a/general.h
+++ b/general.h
@@ -213,6 +213,7 @@ typedef int sh_glist_func_t (GENERIC_LIST *);
 typedef int sh_gcp_func_t (GENERIC_LIST *, char *);
 
 typedef char *sh_string_func_t (char *);       /* like savestring, et al. */
+typedef void *sh_copy_func_t (void *);         /* generic copy function */
 
 typedef int sh_msg_func_t (const char *, ...); /* printf(3)-like */
 typedef void sh_vmsg_func_t (const char *, ...);       /* printf(3)-like */
index a9df3ed6089f89623708b8b21aca0fa29a552bc6..da760ba46cea3c483a5bb14e305ef7ecde295f02 100644 (file)
--- a/hashlib.c
+++ b/hashlib.c
@@ -50,7 +50,7 @@
    don't discard the upper 32 bits of the value, if present. */
 #define HASH_BUCKET(s, t, h) (((h) = hash_string (s)) & ((t)->nbuckets - 1))
 
-static BUCKET_CONTENTS *copy_bucket_array (BUCKET_CONTENTS *, sh_string_func_t *);
+static BUCKET_CONTENTS *copy_bucket_array (BUCKET_CONTENTS *, sh_copy_func_t *);
 
 static void hash_rehash (HASH_TABLE *, int);
 static void hash_grow (HASH_TABLE *);
@@ -88,7 +88,7 @@ hash_size (HASH_TABLE *table)
 /* Copy a hash table bucket array. Call (*cpdata) to copy the data from
    each element. */
 static BUCKET_CONTENTS *
-copy_bucket_array (BUCKET_CONTENTS *ba, sh_string_func_t *cpdata)
+copy_bucket_array (BUCKET_CONTENTS *ba, sh_copy_func_t *cpdata)
 {
   BUCKET_CONTENTS *new_bucket, *n, *e;
 
@@ -171,7 +171,7 @@ hash_shrink (HASH_TABLE *table)
 
 /* Copy an entire hash table. (*cpdata) copies the data in each element. */
 HASH_TABLE *
-hash_copy (HASH_TABLE *table, sh_string_func_t *cpdata)
+hash_copy (HASH_TABLE *table, sh_copy_func_t *cpdata)
 {
   HASH_TABLE *new_table;
   int i;
index 0351ae9d1b2eba6c75248ec5ecc6a88cf255dc71..83ed99b670c85ff2b5dc86d0b1c50b498d70c9bd 100644 (file)
--- a/hashlib.h
+++ b/hashlib.h
@@ -45,7 +45,7 @@ typedef int hash_wfunc (BUCKET_CONTENTS *);
 
 /* Operations on tables as a whole */
 extern HASH_TABLE *hash_create (int);
-extern HASH_TABLE *hash_copy (HASH_TABLE *, sh_string_func_t *);
+extern HASH_TABLE *hash_copy (HASH_TABLE *, sh_copy_func_t *);
 extern void hash_flush (HASH_TABLE *, sh_free_func_t *);
 extern void hash_dispose (HASH_TABLE *);
 extern void hash_walk (HASH_TABLE *, hash_wfunc *);
index 862e37dede7004e2c1ffdc89db86f626b87804a5..744a0df1ea6e0dee473d043c5567e66cc68ca1d5 100644 (file)
Binary files a/po/hr.gmo and b/po/hr.gmo differ
index 158119de3279e56dd32667a950ebfe8c5ec62c3f..961ed2bd05105fb192d24d2c73ca793b6563e281 100644 (file)
--- a/po/hr.po
+++ b/po/hr.po
@@ -9,7 +9,7 @@ msgstr ""
 "Project-Id-Version: bash-5.2-rc1\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2022-01-11 14:50-0500\n"
-"PO-Revision-Date: 2025-02-19 16:48-0800\n"
+"PO-Revision-Date: 2025-03-26 20:56-0700\n"
 "Last-Translator: Božidar Putanec <bozidarp@yahoo.com>\n"
 "Language-Team: Croatian <lokalizacija@linux.hr>\n"
 "Language: hr\n"
@@ -224,7 +224,7 @@ msgstr "nevaljan oktalni broj"
 
 #: builtins/common.c:242
 msgid "invalid hex number"
-msgstr "nevaljan heksadecimalni broj"
+msgstr "nevaljan heksadekadski broj"
 
 #: builtins/common.c:244 expr.c:1574
 msgid "invalid number"
@@ -360,7 +360,7 @@ msgstr "može se koristiti samo u funkciji"
 
 #: builtins/declare.def:437
 msgid "cannot use `-f' to make functions"
-msgstr "„-f” se ne može koristiti za definiranje funkcija"
+msgstr "„-f” nije moguće koristiti za definiranje funkcija"
 
 #: builtins/declare.def:464 execute_cmd.c:6132
 #, c-format
@@ -682,7 +682,7 @@ msgstr "problem s raščlanjivanjem formata: %s"
 
 #: builtins/printf.def:919
 msgid "missing hex digit for \\x"
-msgstr "nema heksadecimalne znamenke za \\x"
+msgstr "nema heksadekadske znamenke za \\x"
 
 #: builtins/printf.def:934
 #, c-format
@@ -1631,12 +1631,12 @@ msgstr "xtrace_set(): %d: nevaljan deskriptor datoteke"
 
 #: print_cmd.c:380
 msgid "xtrace_set: NULL file pointer"
-msgstr "xtrace_set(): pointer datoteke je NULL"
+msgstr "xtrace_set(): pokazivač datoteke je NULL"
 
 #: print_cmd.c:384
 #, c-format
 msgid "xtrace fd (%d) != fileno xtrace fp (%d)"
-msgstr "deskriptor datoteke xtrace (%d) !=  broju datoteke u pointeru datoteke xtrace (%d)"
+msgstr "deskriptor datoteke xtrace (%d) !=  broju datoteke u pokazivaču datoteke xtrace (%d)"
 
 #: print_cmd.c:1545
 #, c-format
@@ -2129,7 +2129,7 @@ msgstr "make_local_variable(): u trenutnom opsegu nema konteksta funkcije"
 #: variables.c:2661
 #, c-format
 msgid "%s: variable may not be assigned value"
-msgstr "%s: varijabli se ne može dodijeliti vrijednost"
+msgstr "%s: varijabli nije moguće dodijeliti vrijednost"
 
 #: variables.c:2818 variables.c:2874
 #, c-format
@@ -2170,7 +2170,7 @@ msgstr "pop_var_context(): nije „global_variables” kontekst"
 
 #: variables.c:5410
 msgid "pop_scope: head of shell_variables not a temporary environment scope"
-msgstr "pop_scope(): vrh od „shell_variables” nije privremeni raspon valjanosti"
+msgstr "pop_scope(): vrh od „shell_variables” nije privremeni doseg okružja"
 
 #: variables.c:6400
 #, c-format
@@ -2827,7 +2827,7 @@ msgstr ""
 "    DIREKTORIJA.\n"
 "\n"
 "    Završi s uspjehom ako je direktorij promijenjen i ako je\n"
-"    varijabla okoline PWD uspješno postavljena kad je dana opcija „-P”;\n"
+"    varijabla okruženja PWD uspješno postavljena kad je dana opcija „-P”;\n"
 "    u suprotnom završi s kȏdom 1."
 
 #: builtins.c:425
@@ -3085,11 +3085,11 @@ msgstr ""
 "      \\v   vertikalni tabulator\n"
 "      \\\\     backslash (\\)\n"
 "      \\0NNN   znak s ASCII kȏdom NNN (oktalni, 1 do 3 oktalne znamenke)\n"
-"      \\xHH    osmobitni znak čija je vrijednost HH (heksadecimalna)\n"
-"      \\uHHHH  unicode znak čija je vrijednost HHHH  (heksadecimalna)\n"
-"                 HHHH može biti od 1 do 4 heksadecimalne znamenke\n"
-"      \\UHHHHHHHH  unicode znak čija je vrijednost HHHH  (heksadecimalna)\n"
-"                     HHHHHHHH može biti od 1 do 8 heksadecimalnih znamenki\n"
+"      \\xHH    osmobitni znak čija je vrijednost HH (heksadekadska)\n"
+"      \\uHHHH  unicode znak čija je vrijednost HHHH  (heksadekadska)\n"
+"                 HHHH može biti od 1 do 4 heksadekadske znamenke\n"
+"      \\UHHHHHHHH  unicode znak čija je vrijednost HHHH  (heksadekadska)\n"
+"                     HHHHHHHH može biti od 1 do 8 heksadekadskih znamenki\n"
 "\n"
 "    Završi s uspjehom osim ako se ne dogodi greška pri pisanju."
 
@@ -3951,7 +3951,7 @@ msgstr ""
 "      -P  ne razriješi simbolične linkove pri izvršavanju naredbi poput „cd”\n"
 "            koje promijene trenutni direktorij\n"
 "      -p  uključi privilegirani način: datoteke BASH_ENV i ENV se zanemare,\n"
-"            funkcije ljuske se ne uvoze iz okoline, a zanemari se i\n"
+"            funkcije ljuske se ne uvoze iz okruženja, a zanemari se i\n"
 "            sve SHELLOPTS; taj način se automatski aktivira kad god se stvarni\n"
 "            i efektivni UID i GID ne podudaraju. Isključivanje ove opcije\n"
 "            učini da je efektivni UID i GID isti kao i stvarni UID i GID.\n"
@@ -4758,7 +4758,7 @@ msgstr ""
 "    trošenja vremena: ukupno potrošeno vrijeme, CPU vrijeme potrošeno\n"
 "    korisnikom i CPU vrijeme potrošeno sustavom za izvršavanje naredbi.\n"
 "\n"
-"    Izlazni format se može prilagoditi s varijablom okoline TIMEFORMAT.\n"
+"    Izlazni format se može prilagoditi s varijablom okruženja TIMEFORMAT.\n"
 "    Opcija „-p” zanemari TIMEFORMAT i ispiše izlaz u prenosivom POSIX\n"
 "    formatu.\n"
 "\n"
diff --git a/shell.c b/shell.c
index b3b51d1ddf7771cbcb645318104444b260d19c51..e59029cc46ebae0c4976ecb567de0b72660bfffd 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -1738,7 +1738,18 @@ set_bash_input (void)
   if (interactive && no_line_editing == 0)
     with_input_from_stdin ();
   else if (interactive == 0)
-    with_input_from_buffered_stream (default_buffered_input, dollar_vars[0]);
+    {
+      errno = 0;
+      with_input_from_buffered_stream (default_buffered_input, dollar_vars[0]);
+      if (get_buffered_stream (default_buffered_input) == NULL)
+       {
+         last_command_exit_value = EX_NOINPUT;
+         if (errno != 0)
+           sys_error ("%s", _("error creating buffered stream"));
+         else
+           report_error ("%s", _("error creating buffered stream"));
+       }
+    }
   else
     with_input_from_stream (default_input, dollar_vars[0]);
 }
diff --git a/subst.c b/subst.c
index 5f4dfc755fcaf32335bee78cd5adc30a83b96de2..284d8e0e67bc4a74052e3b72332a4d873a2368ed 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -7003,9 +7003,9 @@ function_substitute (char *string, int quoted, int flags)
   
   subst_assign_varlist = 0;
 
-  push_context (lambdafunc.name, 1, temporary_env);            /* make local variables work */
   temporary_env = 0;
-  this_shell_function = &lambdafunc;  
+  push_context (lambdafunc.name, 1, temporary_env);            /* make local variables work */
+  this_shell_function = &lambdafunc;
 
   unwind_protect_int (verbose_flag);
   change_flag ('v', FLAG_OFF);
index 0afae3fd23959a90fcca7f5577e14988c4fcb75d..2139f171530bee31a25753d11ec8ec8d0b102154 100755 (executable)
@@ -1,4 +1,4 @@
-: ${BUILD_DIR:==/usr/local/build/bash/bash-current}
+: ${BUILD_DIR:=/usr/local/build/bash/bash-current}
 THIS_SH=$BUILD_DIR/bash
 PATH=$PATH:$BUILD_DIR
 
index 1c582827b4ae76c1b390fe1b07f8c067011972fa..d708c188f7dc065ea6ae3c3d3e8dcc39b30d0b51 100644 (file)
@@ -426,7 +426,7 @@ SEE ALSO
     bash(1)
 
 IMPLEMENTATION
-    Copyright (C) 2024 Free Software Foundation, Inc.
+    Copyright (C) 2025 Free Software Foundation, Inc.
 
 These shell commands are defined internally.  Type `help' to see this list.
 Type `help name' to find out more about the function `name'.
index 3639487f9952e25cbaa9b4eec639af23be93641d..37624e4642b5897a505520d9ccc10fa9e2affa21 100644 (file)
@@ -3656,7 +3656,7 @@ assign_in_env (const WORD_DESC *word, int flags)
 /*                                                                 */
 /* **************************************************************** */
 
-#ifdef INCLUDE_UNUSED
+#if defined (INCLUDE_UNUSED)
 /* Copy VAR to a new data structure and return that structure. */
 SHELL_VAR *
 copy_variable (SHELL_VAR *var)
@@ -4685,6 +4685,31 @@ flush_temporary_env (void)
     }
 }
 
+#if defined (INCLUDE_UNUSED)
+void *
+copyvar (void *v)
+{
+  SHELL_VAR *new;
+  new = copy_variable ((SHELL_VAR *)v);
+  return new;
+}
+
+HASH_TABLE *
+copy_vartab (HASH_TABLE *table)
+{
+  HASH_TABLE *newtab;
+
+  newtab = table ? hash_copy (table, copyvar) : NULL;
+  return newtab;
+}
+
+HASH_TABLE *
+copy_temporary_env (void)
+{
+  return copy_vartab (temporary_env);
+}
+#endif
+
 /* **************************************************************** */
 /*                                                                 */
 /*          Creating and manipulating the environment              */
index 8b33ea6f2c2169c6459c2a879f6953f32c25e52b..201db365c42425b63c30c67b35e02d5f1a18fd3b 100644 (file)
@@ -388,9 +388,12 @@ extern void dispose_builtin_env (void);
 extern void merge_temporary_env (void);
 extern void merge_function_temporary_env (void);
 extern void flush_temporary_env (void);
+extern HASH_TABLE *copy_temporary_env (void);
 extern void merge_builtin_env (void);
 extern void kill_all_local_variables (void);
 
+extern HASH_TABLE *copy_vartab (HASH_TABLE *);
+
 extern void set_var_read_only (char *);
 extern void set_func_read_only (const char *);
 extern void set_var_auto_export (char *);