d285a1f882273b5fee24620a78721ddd648ddeaf
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / bash / 0031-patchlevel-31.patch
1 From http://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-031
2
3 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
4
5                              BASH PATCH REPORT
6                              =================
7
8 Bash-Release:   4.3
9 Patch-ID:       bash43-031
10
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
14
15 Bug-Description:
16
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
19 invalid names.
20
21 Patch (apply with `patch -p0'):
22
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
25 ***************
26 *** 48,51 ****
27 --- 48,52 ----
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 */
31   
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
35 ***************
36 *** 2504,2511 ****
37        int hflags, aflags;
38   {
39 !   char *newval;
40     SHELL_VAR *entry;
41   
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)
45 --- 2566,2590 ----
46        int hflags, aflags;
47   {
48 !   char *newname, *newval;
49     SHELL_VAR *entry;
50 + #if defined (ARRAY_VARS)
51 +   arrayind_t ind;
52 +   char *subp;
53 +   int sublen;
54 + #endif
55   
56 +   newname = 0;
57 + #if defined (ARRAY_VARS)
58 +   if ((aflags & ASS_FROMREF) && (hflags & HASH_NOSRCH) == 0 && valid_array_reference (name))
59 +     {
60 +       newname = array_variable_name (name, &subp, &sublen);
61 +       if (newname == 0)
62 +       return (SHELL_VAR *)NULL;       /* XXX */
63 +       entry = hash_lookup (newname, table);
64 +     }
65 +   else
66 + #endif
67     entry = (hflags & HASH_NOSRCH) ? (SHELL_VAR *)NULL : hash_lookup (name, table);
68
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)
71 ***************
72 *** 2538,2541 ****
73 --- 2617,2630 ----
74         }
75       }
76 + #if defined (ARRAY_VARS)
77 +   else if (entry == 0 && newname)
78 +     {
79 +       entry = make_new_array_variable (newname);      /* indexed array by default */
80 +       if (entry == 0)
81 +       return entry;
82 +       ind = array_expand_index (name, subp, sublen);
83 +       bind_array_element (entry, ind, value, aflags);
84 +     }
85 + #endif
86     else if (entry == 0)
87       {
88 ***************
89 *** 2658,2662 ****
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));
93                     }
94                   else
95 --- 2747,2752 ----
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));
100                     }
101                   else
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
104 ***************
105 *** 26,30 ****
106      looks for to find the patch level (for the sccs version string). */
107   
108 ! #define PATCHLEVEL 30
109   
110   #endif /* _PATCHLEVEL_H_ */
111 --- 26,30 ----
112      looks for to find the patch level (for the sccs version string). */
113   
114 ! #define PATCHLEVEL 31
115   
116   #endif /* _PATCHLEVEL_H_ */