]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/bash/bash50-017
adfcb6a8606081a5233f956c8d7b010924e7dd70
[people/pmueller/ipfire-2.x.git] / src / patches / bash / bash50-017
1 BASH PATCH REPORT
2 =================
3
4 Bash-Release: 5.0
5 Patch-ID: bash50-017
6
7 Bug-Reported-by: Valentin Lab <valentin.lab@kalysto.org>
8 Bug-Reference-ID: <ab981b9c-60a5-46d0-b7e6-a6d88b80df50@kalysto.org>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2020-03/msg00062.html
10
11 Bug-Description:
12
13 There were cases where patch 16 reaped process substitution file descriptors
14 (or FIFOs) and processes to early. This is a better fix for the problem that
15 bash50-016 attempted to solve.
16
17 Patch (apply with `patch -p0'):
18
19 *** ../bash-5.0-patched/subst.c 2019-08-29 11:16:49.000000000 -0400
20 --- subst.c 2020-04-02 16:24:19.000000000 -0400
21 ***************
22 *** 5337,5341 ****
23 }
24
25 ! char *
26 copy_fifo_list (sizep)
27 int *sizep;
28 --- 5337,5341 ----
29 }
30
31 ! void *
32 copy_fifo_list (sizep)
33 int *sizep;
34 ***************
35 *** 5343,5347 ****
36 if (sizep)
37 *sizep = 0;
38 ! return (char *)NULL;
39 }
40
41 --- 5343,5347 ----
42 if (sizep)
43 *sizep = 0;
44 ! return (void *)NULL;
45 }
46
47 ***************
48 *** 5409,5414 ****
49 if (fifo_list[i].file)
50 {
51 ! fifo_list[j].file = fifo_list[i].file;
52 ! fifo_list[j].proc = fifo_list[i].proc;
53 j++;
54 }
55 --- 5409,5419 ----
56 if (fifo_list[i].file)
57 {
58 ! if (i != j)
59 ! {
60 ! fifo_list[j].file = fifo_list[i].file;
61 ! fifo_list[j].proc = fifo_list[i].proc;
62 ! fifo_list[i].file = (char *)NULL;
63 ! fifo_list[i].proc = 0;
64 ! }
65 j++;
66 }
67 ***************
68 *** 5426,5433 ****
69 void
70 close_new_fifos (list, lsize)
71 ! char *list;
72 int lsize;
73 {
74 int i;
75
76 if (list == 0)
77 --- 5431,5439 ----
78 void
79 close_new_fifos (list, lsize)
80 ! void *list;
81 int lsize;
82 {
83 int i;
84 + char *plist;
85
86 if (list == 0)
87 ***************
88 *** 5437,5442 ****
89 }
90
91 ! for (i = 0; i < lsize; i++)
92 ! if (list[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1)
93 unlink_fifo (i);
94
95 --- 5443,5448 ----
96 }
97
98 ! for (plist = (char *)list, i = 0; i < lsize; i++)
99 ! if (plist[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1)
100 unlink_fifo (i);
101
102 ***************
103 *** 5560,5568 ****
104 }
105
106 ! char *
107 copy_fifo_list (sizep)
108 int *sizep;
109 {
110 ! char *ret;
111
112 if (nfds == 0 || totfds == 0)
113 --- 5566,5574 ----
114 }
115
116 ! void *
117 copy_fifo_list (sizep)
118 int *sizep;
119 {
120 ! void *ret;
121
122 if (nfds == 0 || totfds == 0)
123 ***************
124 *** 5570,5579 ****
125 if (sizep)
126 *sizep = 0;
127 ! return (char *)NULL;
128 }
129
130 if (sizep)
131 *sizep = totfds;
132 ! ret = (char *)xmalloc (totfds * sizeof (pid_t));
133 return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t)));
134 }
135 --- 5576,5585 ----
136 if (sizep)
137 *sizep = 0;
138 ! return (void *)NULL;
139 }
140
141 if (sizep)
142 *sizep = totfds;
143 ! ret = xmalloc (totfds * sizeof (pid_t));
144 return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t)));
145 }
146 ***************
147 *** 5648,5655 ****
148 void
149 close_new_fifos (list, lsize)
150 ! char *list;
151 int lsize;
152 {
153 int i;
154
155 if (list == 0)
156 --- 5654,5662 ----
157 void
158 close_new_fifos (list, lsize)
159 ! void *list;
160 int lsize;
161 {
162 int i;
163 + pid_t *plist;
164
165 if (list == 0)
166 ***************
167 *** 5659,5664 ****
168 }
169
170 ! for (i = 0; i < lsize; i++)
171 ! if (list[i] == 0 && i < totfds && dev_fd_list[i])
172 unlink_fifo (i);
173
174 --- 5666,5671 ----
175 }
176
177 ! for (plist = (pid_t *)list, i = 0; i < lsize; i++)
178 ! if (plist[i] == 0 && i < totfds && dev_fd_list[i])
179 unlink_fifo (i);
180
181 *** ../bash-5.0-patched/subst.h 2018-10-21 18:46:09.000000000 -0400
182 --- subst.h 2020-04-02 16:29:28.000000000 -0400
183 ***************
184 *** 274,280 ****
185 extern void unlink_fifo __P((int));
186
187 ! extern char *copy_fifo_list __P((int *));
188 ! extern void unlink_new_fifos __P((char *, int));
189 ! extern void close_new_fifos __P((char *, int));
190
191 extern void clear_fifo_list __P((void));
192 --- 274,279 ----
193 extern void unlink_fifo __P((int));
194
195 ! extern void *copy_fifo_list __P((int *));
196 ! extern void close_new_fifos __P((void *, int));
197
198 extern void clear_fifo_list __P((void));
199 *** ../bash-5.0-patched/execute_cmd.c 2020-02-06 20:16:48.000000000 -0500
200 --- execute_cmd.c 2020-04-02 17:00:10.000000000 -0400
201 ***************
202 *** 565,569 ****
203 #if defined (PROCESS_SUBSTITUTION)
204 volatile int ofifo, nfifo, osize, saved_fifo;
205 ! volatile char *ofifo_list;
206 #endif
207
208 --- 565,569 ----
209 #if defined (PROCESS_SUBSTITUTION)
210 volatile int ofifo, nfifo, osize, saved_fifo;
211 ! volatile void *ofifo_list;
212 #endif
213
214 ***************
215 *** 751,760 ****
216 # endif
217
218 ! if (variable_context != 0) /* XXX - also if sourcelevel != 0? */
219 {
220 ofifo = num_fifos ();
221 ofifo_list = copy_fifo_list ((int *)&osize);
222 begin_unwind_frame ("internal_fifos");
223 ! add_unwind_protect (xfree, ofifo_list);
224 saved_fifo = 1;
225 }
226 --- 751,762 ----
227 # endif
228
229 ! /* XXX - also if sourcelevel != 0? */
230 ! if (variable_context != 0)
231 {
232 ofifo = num_fifos ();
233 ofifo_list = copy_fifo_list ((int *)&osize);
234 begin_unwind_frame ("internal_fifos");
235 ! if (ofifo_list)
236 ! add_unwind_protect (xfree, ofifo_list);
237 saved_fifo = 1;
238 }
239 ***************
240 *** 1100,1123 ****
241 nfifo = num_fifos ();
242 if (nfifo > ofifo)
243 ! close_new_fifos ((char *)ofifo_list, osize);
244 free ((void *)ofifo_list);
245 discard_unwind_frame ("internal_fifos");
246 }
247 - # if defined (HAVE_DEV_FD)
248 - /* Reap process substitutions at the end of loops */
249 - switch (command->type)
250 - {
251 - case cm_while:
252 - case cm_until:
253 - case cm_for:
254 - case cm_group:
255 - # if defined (ARITH_FOR_COMMAND)
256 - case cm_arith_for:
257 - # endif
258 - reap_procsubs ();
259 - default:
260 - break;
261 - }
262 - # endif /* HAVE_DEV_FD */
263 #endif
264
265 --- 1102,1109 ----
266 nfifo = num_fifos ();
267 if (nfifo > ofifo)
268 ! close_new_fifos ((void *)ofifo_list, osize);
269 free ((void *)ofifo_list);
270 discard_unwind_frame ("internal_fifos");
271 }
272 #endif
273
274
275 *** ../bash-5.0/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
276 --- patchlevel.h 2016-10-01 11:01:28.000000000 -0400
277 ***************
278 *** 26,30 ****
279 looks for to find the patch level (for the sccs version string). */
280
281 ! #define PATCHLEVEL 16
282
283 #endif /* _PATCHLEVEL_H_ */
284 --- 26,30 ----
285 looks for to find the patch level (for the sccs version string). */
286
287 ! #define PATCHLEVEL 17
288
289 #endif /* _PATCHLEVEL_H_ */