1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
BASH PATCH REPORT
=================
Bash-Release: 4.0
Patch-ID: bash40-024
Bug-Reported-by: Matt Zyzik <matt.zyzik@nyu.edu>
Bug-Reference-ID: <20090405205428.4FDEA1C7175@ice.filescope.com>
Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2009-04/msg00021.html
Bug-Description:
When using the ** globbing operator, bash will incorrectly add an extra
directory name when the preceding directory name ends with `*' or an empty
string when there is no preceding directory name.
Patch:
*** ../bash-4.0-patched/lib/glob/glob.c 2009-01-04 14:32:30.000000000 -0500
--- lib/glob/glob.c 2009-04-28 10:22:29.000000000 -0400
***************
*** 357,361 ****
if (ep)
*ep = 0;
! if (r)
free (r);
return (struct globval *)0;
--- 357,361 ----
if (ep)
*ep = 0;
! if (r && r != &glob_error_return)
free (r);
return (struct globval *)0;
***************
*** 666,671 ****
}
! /* compat: if GX_ALLDIRS, add the passed directory also */
! if (add_current)
{
sdlen = strlen (dir);
--- 666,672 ----
}
! /* compat: if GX_ALLDIRS, add the passed directory also, but don't add an
! empty directory name. */
! if (add_current && (flags & GX_NULLDIR) == 0)
{
sdlen = strlen (dir);
***************
*** 679,686 ****
nextlink->next = lastlink;
lastlink = nextlink;
! if (flags & GX_NULLDIR)
! nextname[0] = '\0';
! else
! bcopy (dir, nextname, sdlen + 1);
++count;
}
--- 680,684 ----
nextlink->next = lastlink;
lastlink = nextlink;
! bcopy (dir, nextname, sdlen + 1);
++count;
}
***************
*** 943,947 ****
register unsigned int l;
! array = glob_dir_to_array (directories[i], temp_results, flags);
l = 0;
while (array[l] != NULL)
--- 941,950 ----
register unsigned int l;
! /* If we're expanding **, we don't need to glue the directory
! name to the results; we've already done it in glob_vector */
! if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
! array = temp_results;
! else
! array = glob_dir_to_array (directories[i], temp_results, flags);
l = 0;
while (array[l] != NULL)
***************
*** 960,964 ****
/* Note that the elements of ARRAY are not freed. */
! free ((char *) array);
}
}
--- 963,968 ----
/* Note that the elements of ARRAY are not freed. */
! if (array != temp_results)
! free ((char *) array);
}
}
*** ../bash-4.0/patchlevel.h 2009-01-04 14:32:40.000000000 -0500
--- patchlevel.h 2009-02-22 16:11:31.000000000 -0500
***************
*** 26,30 ****
looks for to find the patch level (for the sccs version string). */
! #define PATCHLEVEL 23
#endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
looks for to find the patch level (for the sccs version string). */
! #define PATCHLEVEL 24
#endif /* _PATCHLEVEL_H_ */
|