7 Bug-Reported-by: lolilolicon <lolilolicon@gmail.com>
8 Bug-Reference-ID: <CAMtVo_Nz=32Oq=zWTb6=+8gUNXOo2rRvud1W4oPnA-cgVk_ZqQ@mail.gmail.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-08/msg00139.html
13 The new nameref assignment functionality introduced in bash-4.3 did not perform
14 enough validation on the variable value and would create variables with
17 Patch (apply with `patch -p0'):
22 #define ASS_MKASSOC 0x0004
23 #define ASS_MKGLOBAL 0x0008 /* force global assignment */
24 #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */
25 +#define ASS_FROMREF 0x0020 /* assigning from value of nameref variable */
27 /* Flags for the string extraction functions. */
28 #define SX_NOALLOC 0x0001 /* just skip; don't return substring */
31 @@ -2516,10 +2516,27 @@ bind_variable_internal (name, value, tab
36 + char *newname, *newval;
38 +#if defined (ARRAY_VARS)
45 +#if defined (ARRAY_VARS)
46 + if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name))
48 + newname = array_variable_name (name, &subp, &sublen);
50 + return (SHELL_VAR *)NULL; /* XXX */
51 + entry = hash_lookup (newname, table);
55 entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
57 /* Follow the nameref chain here if this is the global variables table */
58 if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
60 @@ -2550,6 +2567,16 @@ bind_variable_internal (name, value, tab
61 var_setvalue (entry, make_variable_value (entry, value, 0));
64 +#if defined (ARRAY_VARS)
65 + else if (entry == 0 && newname)
67 + entry = make_new_array_variable (newname); /* indexed array by default */
70 + ind = array_expand_index (name, subp, sublen);
71 + bind_array_element (entry, ind, value, aflags);
76 entry = make_new_variable (name, table);
77 @@ -2670,7 +2697,8 @@ bind_variable (name, value, flags)
79 if (nameref_cell (nv) == 0)
80 return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
81 - return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags));
82 + /* XXX - bug here with ref=array[index] */
83 + return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags|ASS_FROMREF));
90 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
91 looks for to find the patch level (for the sccs version string). */
93 -#define PATCHLEVEL 30
94 +#define PATCHLEVEL 31
96 #endif /* _PATCHLEVEL_H_ */