1 From http://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-031
3 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
11 Bug-Reported-by: lolilolicon <lolilolicon@gmail.com>
12 Bug-Reference-ID: <CAMtVo_Nz=32Oq=zWTb6=+8gUNXOo2rRvud1W4oPnA-cgVk_ZqQ@mail.gmail.com>
13 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-08/msg00139.html
17 The new nameref assignment functionality introduced in bash-4.3 did not perform
18 enough validation on the variable value and would create variables with
21 Patch (apply with `patch -p0'):
23 *** a/bash-4.3-patched/subst.h 2014-01-11 21:02:27.000000000 -0500
24 --- b/subst.h 2014-09-01 12:16:56.000000000 -0400
28 #define ASS_MKGLOBAL 0x0008 /* force global assignment */
29 #define ASS_NAMEREF 0x0010 /* assigning to nameref variable */
30 + #define ASS_FROMREF 0x0020 /* assigning from value of nameref variable */
32 /* Flags for the string extraction functions. */
33 *** a/bash-4.3-patched/variables.c 2014-05-15 08:26:50.000000000 -0400
34 --- b/variables.c 2014-09-01 14:37:44.000000000 -0400
42 entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
43 /* Follow the nameref chain here if this is the global variables table */
44 if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
48 ! char *newname, *newval;
50 + #if defined (ARRAY_VARS)
57 + #if defined (ARRAY_VARS)
58 + if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name))
60 + newname = array_variable_name (name, &subp, &sublen);
62 + return (SHELL_VAR *)NULL; /* XXX */
63 + entry = hash_lookup (newname, table);
67 entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
69 /* Follow the nameref chain here if this is the global variables table */
70 if (entry && nameref_p (entry) && (invisible_p (entry) == 0) && table == global_variables->table)
76 + #if defined (ARRAY_VARS)
77 + else if (entry == 0 && newname)
79 + entry = make_new_array_variable (newname); /* indexed array by default */
82 + ind = array_expand_index (name, subp, sublen);
83 + bind_array_element (entry, ind, value, aflags);
90 if (nameref_cell (nv) == 0)
91 return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
92 ! return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags));
96 if (nameref_cell (nv) == 0)
97 return (bind_variable_internal (nv->name, value, nvc->table, 0, flags));
98 ! /* XXX - bug here with ref=array[index] */
99 ! return (bind_variable_internal (nameref_cell (nv), value, nvc->table, 0, flags|ASS_FROMREF));
102 *** a/bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500
103 --- b/patchlevel.h 2014-03-20 20:01:28.000000000 -0400
106 looks for to find the patch level (for the sccs version string). */
108 ! #define PATCHLEVEL 30
110 #endif /* _PATCHLEVEL_H_ */
112 looks for to find the patch level (for the sccs version string). */
114 ! #define PATCHLEVEL 31
116 #endif /* _PATCHLEVEL_H_ */