1 | BASH PATCH REPORT |
---|
2 | ================= |
---|
3 | |
---|
4 | Bash-Release: 4.3 |
---|
5 | Patch-ID: bash43-008 |
---|
6 | |
---|
7 | Bug-Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com> |
---|
8 | Bug-Reference-ID: <20140318135901.GB22158@chaz.gmail.com> |
---|
9 | Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-03/msg00098.html |
---|
10 | |
---|
11 | Bug-Description: |
---|
12 | |
---|
13 | Some extended glob patterns incorrectly matched filenames with a leading |
---|
14 | dot, regardless of the setting of the `dotglob' option. |
---|
15 | |
---|
16 | Patch (apply with `patch -p0'): |
---|
17 | |
---|
18 | *** ../bash-4.3/lib/glob/gmisc.c 2013-10-28 14:45:25.000000000 -0400 |
---|
19 | --- lib/glob/gmisc.c 2014-03-19 09:16:08.000000000 -0400 |
---|
20 | *************** |
---|
21 | *** 211,214 **** |
---|
22 | --- 211,215 ---- |
---|
23 | case '!': |
---|
24 | case '@': |
---|
25 | + case '?': |
---|
26 | return (pat[1] == LPAREN); |
---|
27 | default: |
---|
28 | *** ../bash-4.3/lib/glob/glob.c 2014-01-31 21:43:51.000000000 -0500 |
---|
29 | --- lib/glob/glob.c 2014-03-20 09:01:26.000000000 -0400 |
---|
30 | *************** |
---|
31 | *** 180,202 **** |
---|
32 | int flags; |
---|
33 | { |
---|
34 | ! char *pp, *pe, *t; |
---|
35 | ! int n, r; |
---|
36 | |
---|
37 | pp = pat + 2; |
---|
38 | ! pe = pp + strlen (pp) - 1; /*(*/ |
---|
39 | ! if (*pe != ')') |
---|
40 | ! return 0; |
---|
41 | ! if ((t = strchr (pp, '|')) == 0) /* easy case first */ |
---|
42 | { |
---|
43 | *pe = '\0'; |
---|
44 | r = skipname (pp, dname, flags); /*(*/ |
---|
45 | *pe = ')'; |
---|
46 | return r; |
---|
47 | } |
---|
48 | while (t = glob_patscan (pp, pe, '|')) |
---|
49 | { |
---|
50 | n = t[-1]; |
---|
51 | t[-1] = '\0'; |
---|
52 | r = skipname (pp, dname, flags); |
---|
53 | t[-1] = n; |
---|
54 | if (r == 0) /* if any pattern says not skip, we don't skip */ |
---|
55 | --- 180,215 ---- |
---|
56 | int flags; |
---|
57 | { |
---|
58 | ! char *pp, *pe, *t, *se; |
---|
59 | ! int n, r, negate; |
---|
60 | |
---|
61 | + negate = *pat == '!'; |
---|
62 | pp = pat + 2; |
---|
63 | ! se = pp + strlen (pp) - 1; /* end of string */ |
---|
64 | ! pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */ |
---|
65 | ! /* we should check for invalid extglob pattern here */ |
---|
66 | ! /* if pe != se we have more of the pattern at the end of the extglob |
---|
67 | ! pattern. Check the easy case first ( */ |
---|
68 | ! if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0) |
---|
69 | { |
---|
70 | *pe = '\0'; |
---|
71 | + #if defined (HANDLE_MULTIBYTE) |
---|
72 | + r = mbskipname (pp, dname, flags); |
---|
73 | + #else |
---|
74 | r = skipname (pp, dname, flags); /*(*/ |
---|
75 | + #endif |
---|
76 | *pe = ')'; |
---|
77 | return r; |
---|
78 | } |
---|
79 | + |
---|
80 | + /* check every subpattern */ |
---|
81 | while (t = glob_patscan (pp, pe, '|')) |
---|
82 | { |
---|
83 | n = t[-1]; |
---|
84 | t[-1] = '\0'; |
---|
85 | + #if defined (HANDLE_MULTIBYTE) |
---|
86 | + r = mbskipname (pp, dname, flags); |
---|
87 | + #else |
---|
88 | r = skipname (pp, dname, flags); |
---|
89 | + #endif |
---|
90 | t[-1] = n; |
---|
91 | if (r == 0) /* if any pattern says not skip, we don't skip */ |
---|
92 | *************** |
---|
93 | *** 205,219 **** |
---|
94 | } /*(*/ |
---|
95 | |
---|
96 | ! if (pp == pe) /* glob_patscan might find end of pattern */ |
---|
97 | return r; |
---|
98 | |
---|
99 | ! *pe = '\0'; |
---|
100 | ! # if defined (HANDLE_MULTIBYTE) |
---|
101 | ! r = mbskipname (pp, dname, flags); /*(*/ |
---|
102 | ! # else |
---|
103 | ! r = skipname (pp, dname, flags); /*(*/ |
---|
104 | ! # endif |
---|
105 | ! *pe = ')'; |
---|
106 | ! return r; |
---|
107 | } |
---|
108 | #endif |
---|
109 | --- 218,227 ---- |
---|
110 | } /*(*/ |
---|
111 | |
---|
112 | ! /* glob_patscan might find end of pattern */ |
---|
113 | ! if (pp == se) |
---|
114 | return r; |
---|
115 | |
---|
116 | ! /* but if it doesn't then we didn't match a leading dot */ |
---|
117 | ! return 0; |
---|
118 | } |
---|
119 | #endif |
---|
120 | *************** |
---|
121 | *** 278,289 **** |
---|
122 | { |
---|
123 | #if EXTENDED_GLOB |
---|
124 | ! wchar_t *pp, *pe, *t, n; |
---|
125 | ! int r; |
---|
126 | |
---|
127 | pp = pat + 2; |
---|
128 | ! pe = pp + wcslen (pp) - 1; /*(*/ |
---|
129 | ! if (*pe != L')') |
---|
130 | ! return 0; |
---|
131 | ! if ((t = wcschr (pp, L'|')) == 0) |
---|
132 | { |
---|
133 | *pe = L'\0'; |
---|
134 | --- 286,298 ---- |
---|
135 | { |
---|
136 | #if EXTENDED_GLOB |
---|
137 | ! wchar_t *pp, *pe, *t, n, *se; |
---|
138 | ! int r, negate; |
---|
139 | |
---|
140 | + negate = *pat == L'!'; |
---|
141 | pp = pat + 2; |
---|
142 | ! se = pp + wcslen (pp) - 1; /*(*/ |
---|
143 | ! pe = glob_patscan_wc (pp, se, 0); |
---|
144 | ! |
---|
145 | ! if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0) |
---|
146 | { |
---|
147 | *pe = L'\0'; |
---|
148 | *************** |
---|
149 | *** 292,295 **** |
---|
150 | --- 301,306 ---- |
---|
151 | return r; |
---|
152 | } |
---|
153 | + |
---|
154 | + /* check every subpattern */ |
---|
155 | while (t = glob_patscan_wc (pp, pe, '|')) |
---|
156 | { |
---|
157 | *************** |
---|
158 | *** 306,313 **** |
---|
159 | return r; |
---|
160 | |
---|
161 | ! *pe = L'\0'; |
---|
162 | ! r = wchkname (pp, dname); /*(*/ |
---|
163 | ! *pe = L')'; |
---|
164 | ! return r; |
---|
165 | #else |
---|
166 | return (wchkname (pat, dname)); |
---|
167 | --- 317,322 ---- |
---|
168 | return r; |
---|
169 | |
---|
170 | ! /* but if it doesn't then we didn't match a leading dot */ |
---|
171 | ! return 0; |
---|
172 | #else |
---|
173 | return (wchkname (pat, dname)); |
---|
174 | *** ../bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500 |
---|
175 | --- patchlevel.h 2014-03-20 20:01:28.000000000 -0400 |
---|
176 | *************** |
---|
177 | *** 26,30 **** |
---|
178 | looks for to find the patch level (for the sccs version string). */ |
---|
179 | |
---|
180 | ! #define PATCHLEVEL 7 |
---|
181 | |
---|
182 | #endif /* _PATCHLEVEL_H_ */ |
---|
183 | --- 26,30 ---- |
---|
184 | looks for to find the patch level (for the sccs version string). */ |
---|
185 | |
---|
186 | ! #define PATCHLEVEL 8 |
---|
187 | |
---|
188 | #endif /* _PATCHLEVEL_H_ */ |
---|