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
13 An extended glob pattern containing a slash (`/') causes the globbing code
14 to misinterpret it as a directory separator.
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
22 extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
24 + extern char *glob_dirscan __P((char *, int));
26 /* Compile `glob_loop.c' for single-byte characters. */
27 #define CHAR unsigned char
31 pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */
32 /* we should check for invalid extglob pattern here */
36 /* if pe != se we have more of the pattern at the end of the extglob
37 pattern. Check the easy case first ( */
41 unsigned int result_size;
42 ! char *directory_name, *filename, *dname;
43 unsigned int directory_len;
44 int free_dirname; /* flag */
47 unsigned int result_size;
48 ! char *directory_name, *filename, *dname, *fn;
49 unsigned int directory_len;
50 int free_dirname; /* flag */
54 /* Find the filename. */
55 filename = strrchr (pathname, '/');
56 + #if defined (EXTENDED_GLOB)
57 + if (filename && extended_glob)
59 + fn = glob_dirscan (pathname, '/');
62 + fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename);
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
77 + extern char *glob_patscan __P((char *, char *, int));
79 /* Return 1 of the first character of WSTRING could match the first
80 character of pattern WPAT. Wide character version. */
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
91 + glob_dirscan (pat, dirsep)
95 + char *p, *d, *pe, *se;
98 + for (p = pat; p && *p; p++)
100 + if (extglob_pattern_p (p))
103 + se = p + strlen (p) - 1;
104 + pe = glob_patscan (p + 2, se, 0);
109 + p = pe - 1; /* will do increment above */
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
122 looks for to find the patch level (for the sccs version string). */
124 ! #define PATCHLEVEL 15
126 #endif /* _PATCHLEVEL_H_ */
128 looks for to find the patch level (for the sccs version string). */
130 ! #define PATCHLEVEL 16
132 #endif /* _PATCHLEVEL_H_ */