You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
6.3 KiB

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