]>
Commit | Line | Data |
---|---|---|
1 | BASH PATCH REPORT | |
2 | ================= | |
3 | ||
4 | Bash-Release: 3.2 | |
5 | Patch-ID: bash32-010 | |
6 | ||
7 | Bug-Reported-by: Ryan Waldron <rew@erebor.com> | |
8 | Bug-Reference-ID: <20070119065603.546D011E9C@kansas.erebor.com> | |
9 | Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00059.html | |
10 | ||
11 | Bug-Description: | |
12 | ||
13 | The glibc implementation of regcomp/regexec does not allow backslashes to | |
14 | escape "ordinary" pattern characters when matching. Bash used backslashes | |
15 | to quote all characters when the pattern argument to the [[ special | |
16 | command's =~ operator was quoted. This caused the match to fail on Linux | |
17 | and other systems using GNU libc. | |
18 | ||
19 | Patch: | |
20 | ||
21 | *** ../bash-3.2.9/pathexp.h Sat Feb 19 17:23:18 2005 | |
22 | --- pathexp.h Wed Jan 31 22:53:16 2007 | |
23 | *************** | |
24 | *** 1,5 **** | |
25 | /* pathexp.h -- The shell interface to the globbing library. */ | |
26 | ||
27 | ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc. | |
28 | ||
29 | This file is part of GNU Bash, the Bourne Again SHell. | |
30 | --- 1,5 ---- | |
31 | /* pathexp.h -- The shell interface to the globbing library. */ | |
32 | ||
33 | ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc. | |
34 | ||
35 | This file is part of GNU Bash, the Bourne Again SHell. | |
36 | *************** | |
37 | *** 33,36 **** | |
38 | --- 33,37 ---- | |
39 | #define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */ | |
40 | #define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */ | |
41 | + #define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */ | |
42 | ||
43 | #if defined (EXTENDED_GLOB) | |
44 | *** ../bash-3.2.9/pathexp.c Mon May 6 13:43:05 2002 | |
45 | --- pathexp.c Mon Feb 26 16:59:23 2007 | |
46 | *************** | |
47 | *** 1,5 **** | |
48 | /* pathexp.c -- The shell interface to the globbing library. */ | |
49 | ||
50 | ! /* Copyright (C) 1995-2002 Free Software Foundation, Inc. | |
51 | ||
52 | This file is part of GNU Bash, the Bourne Again SHell. | |
53 | --- 1,5 ---- | |
54 | /* pathexp.c -- The shell interface to the globbing library. */ | |
55 | ||
56 | ! /* Copyright (C) 1995-2007 Free Software Foundation, Inc. | |
57 | ||
58 | This file is part of GNU Bash, the Bourne Again SHell. | |
59 | *************** | |
60 | *** 111,114 **** | |
61 | --- 111,141 ---- | |
62 | } | |
63 | ||
64 | + /* Return 1 if C is a character that is `special' in a POSIX ERE and needs to | |
65 | + be quoted to match itself. */ | |
66 | + static inline int | |
67 | + ere_char (c) | |
68 | + int c; | |
69 | + { | |
70 | + switch (c) | |
71 | + { | |
72 | + case '.': | |
73 | + case '[': | |
74 | + case '\\': | |
75 | + case '(': | |
76 | + case ')': | |
77 | + case '*': | |
78 | + case '+': | |
79 | + case '?': | |
80 | + case '{': | |
81 | + case '|': | |
82 | + case '^': | |
83 | + case '$': | |
84 | + return 1; | |
85 | + default: | |
86 | + return 0; | |
87 | + } | |
88 | + return (0); | |
89 | + } | |
90 | + | |
91 | /* PATHNAME can contain characters prefixed by CTLESC; this indicates | |
92 | that the character is to be quoted. We quote it here in the style | |
93 | *************** | |
94 | *** 143,146 **** | |
95 | --- 170,175 ---- | |
96 | if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/') | |
97 | continue; | |
98 | + if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0) | |
99 | + continue; | |
100 | temp[j++] = '\\'; | |
101 | i++; | |
102 | *** ../bash-3.2.9/subst.c Tue Nov 7 16:14:41 2006 | |
103 | --- subst.c Wed Jan 31 23:09:58 2007 | |
104 | *************** | |
105 | *** 5,9 **** | |
106 | beauty, but, hey, you're alright.'' */ | |
107 | ||
108 | ! /* Copyright (C) 1987-2006 Free Software Foundation, Inc. | |
109 | ||
110 | This file is part of GNU Bash, the Bourne Again SHell. | |
111 | --- 5,9 ---- | |
112 | beauty, but, hey, you're alright.'' */ | |
113 | ||
114 | ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc. | |
115 | ||
116 | This file is part of GNU Bash, the Bourne Again SHell. | |
117 | *************** | |
118 | *** 2647,2655 **** | |
119 | /* This needs better error handling. */ | |
120 | /* Expand W for use as an argument to a unary or binary operator in a | |
121 | ! [[...]] expression. If SPECIAL is nonzero, this is the rhs argument | |
122 | to the != or == operator, and should be treated as a pattern. In | |
123 | ! this case, we quote the string specially for the globbing code. The | |
124 | ! caller is responsible for removing the backslashes if the unquoted | |
125 | ! words is needed later. */ | |
126 | char * | |
127 | cond_expand_word (w, special) | |
128 | --- 2647,2656 ---- | |
129 | /* This needs better error handling. */ | |
130 | /* Expand W for use as an argument to a unary or binary operator in a | |
131 | ! [[...]] expression. If SPECIAL is 1, this is the rhs argument | |
132 | to the != or == operator, and should be treated as a pattern. In | |
133 | ! this case, we quote the string specially for the globbing code. If | |
134 | ! SPECIAL is 2, this is an rhs argument for the =~ operator, and should | |
135 | ! be quoted appropriately for regcomp/regexec. The caller is responsible | |
136 | ! for removing the backslashes if the unquoted word is needed later. */ | |
137 | char * | |
138 | cond_expand_word (w, special) | |
139 | *************** | |
140 | *** 2659,2662 **** | |
141 | --- 2660,2664 ---- | |
142 | char *r, *p; | |
143 | WORD_LIST *l; | |
144 | + int qflags; | |
145 | ||
146 | if (w->word == 0 || w->word[0] == '\0') | |
147 | *************** | |
148 | *** 2673,2678 **** | |
149 | else | |
150 | { | |
151 | p = string_list (l); | |
152 | ! r = quote_string_for_globbing (p, QGLOB_CVTNULL); | |
153 | free (p); | |
154 | } | |
155 | --- 2675,2683 ---- | |
156 | else | |
157 | { | |
158 | + qflags = QGLOB_CVTNULL; | |
159 | + if (special == 2) | |
160 | + qflags |= QGLOB_REGEXP; | |
161 | p = string_list (l); | |
162 | ! r = quote_string_for_globbing (p, qflags); | |
163 | free (p); | |
164 | } | |
165 | *** ../bash-3.2.9/execute_cmd.c Sat Aug 26 00:23:17 2006 | |
166 | --- execute_cmd.c Wed Jan 31 23:12:06 2007 | |
167 | *************** | |
168 | *** 1,5 **** | |
169 | /* execute_cmd.c -- Execute a COMMAND structure. */ | |
170 | ||
171 | ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc. | |
172 | ||
173 | This file is part of GNU Bash, the Bourne Again SHell. | |
174 | --- 1,5 ---- | |
175 | /* execute_cmd.c -- Execute a COMMAND structure. */ | |
176 | ||
177 | ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc. | |
178 | ||
179 | This file is part of GNU Bash, the Bourne Again SHell. | |
180 | *************** | |
181 | *** 2547,2551 **** | |
182 | if (arg1 == 0) | |
183 | arg1 = nullstr; | |
184 | ! arg2 = cond_expand_word (cond->right->op, patmatch||rmatch); | |
185 | if (arg2 == 0) | |
186 | arg2 = nullstr; | |
187 | --- 2547,2551 ---- | |
188 | if (arg1 == 0) | |
189 | arg1 = nullstr; | |
190 | ! arg2 = cond_expand_word (cond->right->op, rmatch ? 2 : (patmatch ? 1 : 0)); | |
191 | if (arg2 == 0) | |
192 | arg2 = nullstr; | |
193 | *** ../bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006 | |
194 | --- patchlevel.h Mon Oct 16 14:22:54 2006 | |
195 | *************** | |
196 | *** 26,30 **** | |
197 | looks for to find the patch level (for the sccs version string). */ | |
198 | ||
199 | ! #define PATCHLEVEL 9 | |
200 | ||
201 | #endif /* _PATCHLEVEL_H_ */ | |
202 | --- 26,30 ---- | |
203 | looks for to find the patch level (for the sccs version string). */ | |
204 | ||
205 | ! #define PATCHLEVEL 10 | |
206 | ||
207 | #endif /* _PATCHLEVEL_H_ */ |