]>
Commit | Line | Data |
---|---|---|
ce84ace5 MT |
1 | BASH PATCH REPORT |
2 | ================= | |
3 | ||
4 | Bash-Release: 4.3 | |
5 | Patch-ID: bash43-016 | |
6 | ||
7 | Bug-Reported-by: Pierre Gaston <pierre.gaston@gmail.com> | |
8 | Bug-Reference-ID: <CAPSX3sTCD61k1VQLJ5r-LWzEt+e7Xc-fxXmwn2u8EA5gJJej8Q@mail.gmail.com> | |
9 | Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2014-04/msg00100.html | |
10 | ||
11 | Bug-Description: | |
12 | ||
13 | An extended glob pattern containing a slash (`/') causes the globbing code | |
14 | to misinterpret it as a directory separator. | |
15 | ||
16 | Patch (apply with `patch -p0'): | |
17 | *** ../bash-4.3-patched/lib/glob/glob.c 2014-03-28 10:54:23.000000000 -0400 | |
18 | --- lib/glob/glob.c 2014-05-02 10:24:28.000000000 -0400 | |
19 | *************** | |
20 | *** 124,127 **** | |
21 | --- 124,129 ---- | |
22 | extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int)); | |
23 | ||
24 | + extern char *glob_dirscan __P((char *, int)); | |
25 | + | |
26 | /* Compile `glob_loop.c' for single-byte characters. */ | |
27 | #define CHAR unsigned char | |
28 | *************** | |
29 | *** 188,191 **** | |
30 | --- 190,196 ---- | |
31 | pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */ | |
32 | /* we should check for invalid extglob pattern here */ | |
33 | + if (pe == 0) | |
34 | + return 0; | |
35 | + | |
36 | /* if pe != se we have more of the pattern at the end of the extglob | |
37 | pattern. Check the easy case first ( */ | |
38 | *************** | |
39 | *** 1016,1020 **** | |
40 | char **result; | |
41 | unsigned int result_size; | |
42 | ! char *directory_name, *filename, *dname; | |
43 | unsigned int directory_len; | |
44 | int free_dirname; /* flag */ | |
45 | --- 1021,1025 ---- | |
46 | char **result; | |
47 | unsigned int result_size; | |
48 | ! char *directory_name, *filename, *dname, *fn; | |
49 | unsigned int directory_len; | |
50 | int free_dirname; /* flag */ | |
51 | *************** | |
52 | *** 1032,1035 **** | |
53 | --- 1037,1052 ---- | |
54 | /* Find the filename. */ | |
55 | filename = strrchr (pathname, '/'); | |
56 | + #if defined (EXTENDED_GLOB) | |
57 | + if (filename && extended_glob) | |
58 | + { | |
59 | + fn = glob_dirscan (pathname, '/'); | |
60 | + #if DEBUG_MATCHING | |
61 | + if (fn != filename) | |
62 | + fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename); | |
63 | + #endif | |
64 | + filename = fn; | |
65 | + } | |
66 | + #endif | |
67 | + | |
68 | if (filename == NULL) | |
69 | { | |
70 | *** ../bash-4.3-patched/lib/glob/gmisc.c 2014-03-28 10:54:23.000000000 -0400 | |
71 | --- lib/glob/gmisc.c 2014-05-02 09:35:57.000000000 -0400 | |
72 | *************** | |
73 | *** 43,46 **** | |
74 | --- 43,48 ---- | |
75 | #define WRPAREN L')' | |
76 | ||
77 | + extern char *glob_patscan __P((char *, char *, int)); | |
78 | + | |
79 | /* Return 1 of the first character of WSTRING could match the first | |
80 | character of pattern WPAT. Wide character version. */ | |
81 | *************** | |
82 | *** 376,377 **** | |
83 | --- 378,410 ---- | |
84 | return matlen; | |
85 | } | |
86 | + | |
87 | + /* Skip characters in PAT and return the final occurrence of DIRSEP. This | |
88 | + is only called when extended_glob is set, so we have to skip over extglob | |
89 | + patterns x(...) */ | |
90 | + char * | |
91 | + glob_dirscan (pat, dirsep) | |
92 | + char *pat; | |
93 | + int dirsep; | |
94 | + { | |
95 | + char *p, *d, *pe, *se; | |
96 | + | |
97 | + d = pe = se = 0; | |
98 | + for (p = pat; p && *p; p++) | |
99 | + { | |
100 | + if (extglob_pattern_p (p)) | |
101 | + { | |
102 | + if (se == 0) | |
103 | + se = p + strlen (p) - 1; | |
104 | + pe = glob_patscan (p + 2, se, 0); | |
105 | + if (pe == 0) | |
106 | + continue; | |
107 | + else if (*pe == 0) | |
108 | + break; | |
109 | + p = pe - 1; /* will do increment above */ | |
110 | + continue; | |
111 | + } | |
112 | + if (*p == dirsep) | |
113 | + d = p; | |
114 | + } | |
115 | + return d; | |
116 | + } | |
117 | ||
118 | *** ../bash-4.3/patchlevel.h 2012-12-29 10:47:57.000000000 -0500 | |
119 | --- patchlevel.h 2014-03-20 20:01:28.000000000 -0400 | |
120 | *************** | |
121 | *** 26,30 **** | |
122 | looks for to find the patch level (for the sccs version string). */ | |
123 | ||
124 | ! #define PATCHLEVEL 15 | |
125 | ||
126 | #endif /* _PATCHLEVEL_H_ */ | |
127 | --- 26,30 ---- | |
128 | looks for to find the patch level (for the sccs version string). */ | |
129 | ||
130 | ! #define PATCHLEVEL 16 | |
131 | ||
132 | #endif /* _PATCHLEVEL_H_ */ |