]> git.pld-linux.org Git - packages/bash.git/blame - bash42-030
up to 4.2.45
[packages/bash.git] / bash42-030
CommitLineData
e5ec3c9c
ER
1 BASH PATCH REPORT
2 =================
3
4Bash-Release: 4.2
5Patch-ID: bash42-030
6
7Bug-Reported-by: Roman Rakus <rrakus@redhat.com>
8Bug-Reference-ID: <4D7DD91E.7040808@redhat.com>
9Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2011-03/msg00126.html
10
11Bug-Description:
12
13When attempting to glob strings in a multibyte locale, and those strings
14contain invalid multibyte characters that cause mbsnrtowcs to return 0,
15the globbing code loops infinitely.
16
17Patch (apply with `patch -p0'):
18
19*** ../bash-4.2-patched/lib/glob/xmbsrtowcs.c 2010-05-30 18:36:27.000000000 -0400
20--- lib/glob/xmbsrtowcs.c 2011-03-22 16:06:47.000000000 -0400
21***************
22*** 36,39 ****
23--- 36,41 ----
24 #if HANDLE_MULTIBYTE
25
26+ #define WSBUF_INC 32
27+
28 #ifndef FREE
29 # define FREE(x) do { if (x) free (x); } while (0)
30***************
31*** 149,153 ****
32 size_t wcnum; /* Number of wide characters in WSBUF */
33 mbstate_t state; /* Conversion State */
34! size_t wcslength; /* Number of wide characters produced by the conversion. */
35 const char *end_or_backslash;
36 size_t nms; /* Number of multibyte characters to convert at one time. */
37--- 151,155 ----
38 size_t wcnum; /* Number of wide characters in WSBUF */
39 mbstate_t state; /* Conversion State */
40! size_t n, wcslength; /* Number of wide characters produced by the conversion. */
41 const char *end_or_backslash;
42 size_t nms; /* Number of multibyte characters to convert at one time. */
43***************
44*** 172,176 ****
45 tmp_p = p;
46 tmp_state = state;
47! wcslength = mbsnrtowcs(NULL, &tmp_p, nms, 0, &tmp_state);
48
49 /* Conversion failed. */
50--- 174,189 ----
51 tmp_p = p;
52 tmp_state = state;
53!
54! if (nms == 0 && *p == '\\') /* special initial case */
55! nms = wcslength = 1;
56! else
57! wcslength = mbsnrtowcs (NULL, &tmp_p, nms, 0, &tmp_state);
58!
59! if (wcslength == 0)
60! {
61! tmp_p = p; /* will need below */
62! tmp_state = state;
63! wcslength = 1; /* take a single byte */
64! }
65
66 /* Conversion failed. */
67***************
68*** 187,191 ****
69 wchar_t *wstmp;
70
71! wsbuf_size = wcnum+wcslength+1; /* 1 for the L'\0' or the potential L'\\' */
72
73 wstmp = (wchar_t *) realloc (wsbuf, wsbuf_size * sizeof (wchar_t));
74--- 200,205 ----
75 wchar_t *wstmp;
76
77! while (wsbuf_size < wcnum+wcslength+1) /* 1 for the L'\0' or the potential L'\\' */
78! wsbuf_size += WSBUF_INC;
79
80 wstmp = (wchar_t *) realloc (wsbuf, wsbuf_size * sizeof (wchar_t));
81***************
82*** 200,207 ****
83
84 /* Perform the conversion. This is assumed to return 'wcslength'.
85! * It may set 'p' to NULL. */
86! mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
87
88! wcnum += wcslength;
89
90 if (mbsinit (&state) && (p != NULL) && (*p == '\\'))
91--- 214,229 ----
92
93 /* Perform the conversion. This is assumed to return 'wcslength'.
94! It may set 'p' to NULL. */
95! n = mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
96
97! /* Compensate for taking single byte on wcs conversion failure above. */
98! if (wcslength == 1 && (n == 0 || n == (size_t)-1))
99! {
100! state = tmp_state;
101! p = tmp_p;
102! wsbuf[wcnum++] = *p++;
103! }
104! else
105! wcnum += wcslength;
106
107 if (mbsinit (&state) && (p != NULL) && (*p == '\\'))
108***************
109*** 231,236 ****
110 of DESTP and INDICESP are NULL. */
111
112- #define WSBUF_INC 32
113-
114 size_t
115 xdupmbstowcs (destp, indicesp, src)
116--- 253,256 ----
117*** ../bash-4.2-patched/lib/glob/glob.c 2009-11-14 18:39:30.000000000 -0500
118--- lib/glob/glob.c 2012-07-07 12:09:56.000000000 -0400
119***************
120*** 201,206 ****
121 size_t pat_n, dn_n;
122
123 pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
124! dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
125
126 ret = 0;
127--- 201,209 ----
128 size_t pat_n, dn_n;
129
130+ pat_wc = dn_wc = (wchar_t *)NULL;
131+
132 pat_n = xdupmbstowcs (&pat_wc, NULL, pat);
133! if (pat_n != (size_t)-1)
134! dn_n = xdupmbstowcs (&dn_wc, NULL, dname);
135
136 ret = 0;
137***************
138*** 222,225 ****
139--- 225,230 ----
140 ret = 1;
141 }
142+ else
143+ ret = skipname (pat, dname, flags);
144
145 FREE (pat_wc);
146***************
147*** 267,272 ****
148 n = xdupmbstowcs (&wpathname, NULL, pathname);
149 if (n == (size_t) -1)
150! /* Something wrong. */
151! return;
152 orig_wpathname = wpathname;
153
154--- 272,280 ----
155 n = xdupmbstowcs (&wpathname, NULL, pathname);
156 if (n == (size_t) -1)
157! {
158! /* Something wrong. Fall back to single-byte */
159! udequote_pathname (pathname);
160! return;
161! }
162 orig_wpathname = wpathname;
163
164*** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
165--- patchlevel.h Thu Feb 24 21:41:34 2011
166***************
167*** 26,30 ****
168 looks for to find the patch level (for the sccs version string). */
169
170! #define PATCHLEVEL 29
171
172 #endif /* _PATCHLEVEL_H_ */
173--- 26,30 ----
174 looks for to find the patch level (for the sccs version string). */
175
176! #define PATCHLEVEL 30
177
178 #endif /* _PATCHLEVEL_H_ */
This page took 0.03955 seconds and 4 git commands to generate.