~ubuntu-branches/ubuntu/trusty/bash/trusty-security

« back to all changes in this revision

Viewing changes to debian/patches/bash42-025.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-03-03 22:52:05 UTC
  • mfrom: (1.3.5) (2.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20140303225205-87ltrt5kspeq0g1b
Tags: 4.3-1ubuntu1
* Merge with Debian; remaining changes:
  - skel.bashrc:
    - Run lesspipe.
    - Enable ls aliases.
    - Set options in ll alias to -alF.
    - Define an alert alias.
    - Enabled colored grep aliases.
  - etc.bash.bashrc:
    - Add sudo hint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
                             BASH PATCH REPORT
2
 
                             =================
3
 
 
4
 
Bash-Release:   4.2
5
 
Patch-ID:       bash42-025
6
 
 
7
 
Bug-Reported-by:        Bill Gradwohl <bill@ycc.com>
8
 
Bug-Reference-ID:       <CAFyvKis-UfuOWr5THBRKh=vYHDoKEEgdW8hN1RviTuYQ00Lu5A@mail.gmail.com>
9
 
Bug-Reference-URL:      http://lists.gnu.org/archive/html/help-bash/2012-03/msg00078.html
10
 
 
11
 
Bug-Description:
12
 
 
13
 
When used in a shell function, `declare -g -a array=(compound assignment)'
14
 
creates a local variable instead of a global one.
15
 
 
16
 
Patch (apply with `patch -p0'):
17
 
 
18
 
Index: b/bash/command.h
19
 
===================================================================
20
 
--- a/bash/command.h
21
 
+++ b/bash/command.h
22
 
@@ -97,6 +97,7 @@
23
 
 #define W_HASCTLESC    0x200000        /* word contains literal CTLESC characters */
24
 
 #define W_ASSIGNASSOC  0x400000        /* word looks like associative array assignment */
25
 
 #define W_ARRAYIND     0x800000        /* word is an array index being expanded */
26
 
+#define W_ASSNGLOBAL   0x1000000       /* word is a global assignment to declare (declare/typeset -g) */
27
 
 
28
 
 /* Possible values for subshell_environment */
29
 
 #define SUBSHELL_ASYNC 0x01    /* subshell caused by `command &' */
30
 
Index: b/bash/execute_cmd.c
31
 
===================================================================
32
 
--- a/bash/execute_cmd.c
33
 
+++ b/bash/execute_cmd.c
34
 
@@ -3580,13 +3580,13 @@
35
 
 {
36
 
   WORD_LIST *w;
37
 
   struct builtin *b;
38
 
-  int assoc;
39
 
+  int assoc, global;
40
 
 
41
 
   if (words == 0)
42
 
     return;
43
 
 
44
 
   b = 0;
45
 
-  assoc = 0;
46
 
+  assoc = global = 0;
47
 
 
48
 
   for (w = words; w; w = w->next)
49
 
     if (w->word->flags & W_ASSIGNMENT)
50
 
@@ -3603,12 +3603,17 @@
51
 
 #if defined (ARRAY_VARS)
52
 
        if (assoc)
53
 
          w->word->flags |= W_ASSIGNASSOC;
54
 
+       if (global)
55
 
+         w->word->flags |= W_ASSNGLOBAL;
56
 
 #endif
57
 
       }
58
 
 #if defined (ARRAY_VARS)
59
 
     /* Note that we saw an associative array option to a builtin that takes
60
 
        assignment statements.  This is a bit of a kludge. */
61
 
-    else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
62
 
+    else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
63
 
+#else
64
 
+    else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
65
 
+#endif
66
 
       {
67
 
        if (b == 0)
68
 
          {
69
 
@@ -3618,10 +3623,11 @@
70
 
            else if (b && (b->flags & ASSIGNMENT_BUILTIN))
71
 
              words->word->flags |= W_ASSNBLTIN;
72
 
          }
73
 
-       if (words->word->flags & W_ASSNBLTIN)
74
 
+       if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
75
 
          assoc = 1;
76
 
+       if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
77
 
+         global = 1;
78
 
       }
79
 
-#endif
80
 
 }
81
 
 
82
 
 /* Return 1 if the file found by searching $PATH for PATHNAME, defaulting
83
 
Index: b/bash/patchlevel.h
84
 
===================================================================
85
 
--- a/bash/patchlevel.h
86
 
+++ b/bash/patchlevel.h
87
 
@@ -25,6 +25,6 @@
88
 
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
89
 
    looks for to find the patch level (for the sccs version string). */
90
 
 
91
 
-#define PATCHLEVEL 24
92
 
+#define PATCHLEVEL 25
93
 
 
94
 
 #endif /* _PATCHLEVEL_H_ */
95
 
Index: b/bash/subst.c
96
 
===================================================================
97
 
--- a/bash/subst.c
98
 
+++ b/bash/subst.c
99
 
@@ -366,6 +366,11 @@
100
 
       f &= ~W_ASSNBLTIN;
101
 
       fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
102
 
     }
103
 
+  if (f & W_ASSNGLOBAL)
104
 
+    {
105
 
+      f &= ~W_ASSNGLOBAL;
106
 
+      fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
107
 
+    }
108
 
   if (f & W_COMPASSIGN)
109
 
     {
110
 
       f &= ~W_COMPASSIGN;
111
 
@@ -2803,7 +2808,7 @@
112
 
     }
113
 
   else if (assign_list)
114
 
     {
115
 
-      if (word->flags & W_ASSIGNARG)
116
 
+      if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
117
 
        aflags |= ASS_MKLOCAL;
118
 
       if (word->flags & W_ASSIGNASSOC)
119
 
        aflags |= ASS_MKASSOC;