bash32-019 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 3.2
  4. Patch-ID: bash32-019
  5. Bug-Reported-by: Thomas Loeber <ifp@loeber1.de>
  6. Bug-Reference-ID: <200703082223.08919.ifp@loeber1.de>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-03/msg00036.html
  8. Bug-Description:
  9. When rl_read_key returns -1, indicating that bash's controlling terminal
  10. has been invalidated for some reason (e.g., receiving a SIGHUP), the error
  11. status was not reported correctly to the caller. This could cause input
  12. loops.
  13. Patch:
  14. *** ../bash-3.2-patched/lib/readline/complete.c Fri Jul 28 11:35:49 2006
  15. --- bash-3.2/lib/readline/complete.c Tue Mar 13 08:50:16 2007
  16. ***************
  17. *** 429,433 ****
  18. if (c == 'n' || c == 'N' || c == RUBOUT)
  19. return (0);
  20. ! if (c == ABORT_CHAR)
  21. _rl_abort_internal ();
  22. if (for_pager && (c == NEWLINE || c == RETURN))
  23. --- 440,444 ----
  24. if (c == 'n' || c == 'N' || c == RUBOUT)
  25. return (0);
  26. ! if (c == ABORT_CHAR || c < 0)
  27. _rl_abort_internal ();
  28. if (for_pager && (c == NEWLINE || c == RETURN))
  29. *** ../bash-3.2-patched/lib/readline/input.c Wed Aug 16 15:15:16 2006
  30. --- bash-3.2/lib/readline/input.c Wed May 2 16:07:59 2007
  31. ***************
  32. *** 514,518 ****
  33. int size;
  34. {
  35. ! int mb_len = 0;
  36. size_t mbchar_bytes_length;
  37. wchar_t wc;
  38. --- 522,526 ----
  39. int size;
  40. {
  41. ! int mb_len, c;
  42. size_t mbchar_bytes_length;
  43. wchar_t wc;
  44. ***************
  45. *** 521,531 ****
  46. memset(&ps, 0, sizeof (mbstate_t));
  47. memset(&ps_back, 0, sizeof (mbstate_t));
  48. !
  49. while (mb_len < size)
  50. {
  51. RL_SETSTATE(RL_STATE_MOREINPUT);
  52. ! mbchar[mb_len++] = rl_read_key ();
  53. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  54. mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
  55. if (mbchar_bytes_length == (size_t)(-1))
  56. --- 529,545 ----
  57. memset(&ps, 0, sizeof (mbstate_t));
  58. memset(&ps_back, 0, sizeof (mbstate_t));
  59. !
  60. ! mb_len = 0;
  61. while (mb_len < size)
  62. {
  63. RL_SETSTATE(RL_STATE_MOREINPUT);
  64. ! c = rl_read_key ();
  65. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  66. + if (c < 0)
  67. + break;
  68. +
  69. + mbchar[mb_len++] = c;
  70. +
  71. mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
  72. if (mbchar_bytes_length == (size_t)(-1))
  73. ***************
  74. *** 565,569 ****
  75. c = first;
  76. memset (mb, 0, mlen);
  77. ! for (i = 0; i < mlen; i++)
  78. {
  79. mb[i] = (char)c;
  80. --- 579,583 ----
  81. c = first;
  82. memset (mb, 0, mlen);
  83. ! for (i = 0; c >= 0 && i < mlen; i++)
  84. {
  85. mb[i] = (char)c;
  86. *** ../bash-3.2-patched/lib/readline/isearch.c Mon Dec 26 17:18:53 2005
  87. --- bash-3.2/lib/readline/isearch.c Fri Mar 9 14:30:59 2007
  88. ***************
  89. *** 328,333 ****
  90. f = (rl_command_func_t *)NULL;
  91. !
  92. ! /* Translate the keys we do something with to opcodes. */
  93. if (c >= 0 && _rl_keymap[c].type == ISFUNC)
  94. {
  95. --- 328,340 ----
  96. f = (rl_command_func_t *)NULL;
  97. !
  98. ! if (c < 0)
  99. ! {
  100. ! cxt->sflags |= SF_FAILED;
  101. ! cxt->history_pos = cxt->last_found_line;
  102. ! return -1;
  103. ! }
  104. !
  105. ! /* Translate the keys we do something with to opcodes. */
  106. if (c >= 0 && _rl_keymap[c].type == ISFUNC)
  107. {
  108. *** ../bash-3.2-patched/lib/readline/misc.c Mon Dec 26 17:20:46 2005
  109. --- bash-3.2/lib/readline/misc.c Fri Mar 9 14:44:11 2007
  110. ***************
  111. *** 147,150 ****
  112. --- 147,152 ----
  113. rl_clear_message ();
  114. RL_UNSETSTATE(RL_STATE_NUMERICARG);
  115. + if (key < 0)
  116. + return -1;
  117. return (_rl_dispatch (key, _rl_keymap));
  118. }
  119. *** ../bash-3.2-patched/lib/readline/readline.c Wed Aug 16 15:00:36 2006
  120. --- bash-3.2/lib/readline/readline.c Fri Mar 9 14:47:24 2007
  121. ***************
  122. *** 646,649 ****
  123. --- 669,677 ----
  124. {
  125. nkey = _rl_subseq_getchar (cxt->okey);
  126. + if (nkey < 0)
  127. + {
  128. + _rl_abort_internal ();
  129. + return -1;
  130. + }
  131. r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
  132. cxt->flags |= KSEQ_DISPATCHED;
  133. *** ../bash-3.2-patched/lib/readline/text.c Fri Jul 28 11:55:27 2006
  134. --- bash-3.2/lib/readline/text.c Sun Mar 25 13:41:38 2007
  135. ***************
  136. *** 858,861 ****
  137. --- 864,870 ----
  138. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  139. + if (c < 0)
  140. + return -1;
  141. +
  142. #if defined (HANDLE_SIGNALS)
  143. if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
  144. ***************
  145. *** 1521,1524 ****
  146. --- 1530,1536 ----
  147. mb_len = _rl_read_mbchar (mbchar, MB_LEN_MAX);
  148. + if (mb_len <= 0)
  149. + return -1;
  150. +
  151. if (count < 0)
  152. return (_rl_char_search_internal (-count, bdir, mbchar, mb_len));
  153. ***************
  154. *** 1537,1540 ****
  155. --- 1549,1555 ----
  156. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  157. + if (c < 0)
  158. + return -1;
  159. +
  160. if (count < 0)
  161. return (_rl_char_search_internal (-count, bdir, c));
  162. *** ../bash-3.2-patched/lib/readline/vi_mode.c Sat Jul 29 16:42:28 2006
  163. --- bash-3.2/lib/readline/vi_mode.c Fri Mar 9 15:02:11 2007
  164. ***************
  165. *** 887,890 ****
  166. --- 887,897 ----
  167. c = rl_read_key ();
  168. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  169. +
  170. + if (c < 0)
  171. + {
  172. + *nextkey = 0;
  173. + return -1;
  174. + }
  175. +
  176. *nextkey = c;
  177. ***************
  178. *** 903,906 ****
  179. --- 910,918 ----
  180. c = rl_read_key (); /* real command */
  181. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  182. + if (c < 0)
  183. + {
  184. + *nextkey = 0;
  185. + return -1;
  186. + }
  187. *nextkey = c;
  188. }
  189. ***************
  190. *** 1225,1236 ****
  191. _rl_callback_generic_arg *data;
  192. {
  193. #if defined (HANDLE_MULTIBYTE)
  194. ! _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
  195. #else
  196. RL_SETSTATE(RL_STATE_MOREINPUT);
  197. ! _rl_vi_last_search_char = rl_read_key ();
  198. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  199. #endif
  200. _rl_callback_func = 0;
  201. _rl_want_redisplay = 1;
  202. --- 1243,1262 ----
  203. _rl_callback_generic_arg *data;
  204. {
  205. + int c;
  206. #if defined (HANDLE_MULTIBYTE)
  207. ! c = _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
  208. #else
  209. RL_SETSTATE(RL_STATE_MOREINPUT);
  210. ! c = rl_read_key ();
  211. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  212. #endif
  213. + if (c <= 0)
  214. + return -1;
  215. +
  216. + #if !defined (HANDLE_MULTIBYTE)
  217. + _rl_vi_last_search_char = c;
  218. + #endif
  219. +
  220. _rl_callback_func = 0;
  221. _rl_want_redisplay = 1;
  222. ***************
  223. *** 1248,1251 ****
  224. --- 1274,1278 ----
  225. int count, key;
  226. {
  227. + int c;
  228. #if defined (HANDLE_MULTIBYTE)
  229. static char *target;
  230. ***************
  231. *** 1294,1302 ****
  232. {
  233. #if defined (HANDLE_MULTIBYTE)
  234. ! _rl_vi_last_search_mblen = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
  235. #else
  236. RL_SETSTATE(RL_STATE_MOREINPUT);
  237. ! _rl_vi_last_search_char = rl_read_key ();
  238. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  239. #endif
  240. }
  241. --- 1321,1335 ----
  242. {
  243. #if defined (HANDLE_MULTIBYTE)
  244. ! c = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
  245. ! if (c <= 0)
  246. ! return -1;
  247. ! _rl_vi_last_search_mblen = c;
  248. #else
  249. RL_SETSTATE(RL_STATE_MOREINPUT);
  250. ! c = rl_read_key ();
  251. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  252. + if (c < 0)
  253. + return -1;
  254. + _rl_vi_last_search_char = c;
  255. #endif
  256. }
  257. ***************
  258. *** 1468,1471 ****
  259. --- 1501,1507 ----
  260. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  261. + if (c < 0)
  262. + return -1;
  263. +
  264. #if defined (HANDLE_MULTIBYTE)
  265. if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
  266. ***************
  267. *** 1486,1489 ****
  268. --- 1522,1528 ----
  269. _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
  270. + if (c < 0)
  271. + return -1;
  272. +
  273. _rl_callback_func = 0;
  274. _rl_want_redisplay = 1;
  275. ***************
  276. *** 1517,1520 ****
  277. --- 1556,1562 ----
  278. _rl_vi_last_replacement = c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
  279. + if (c < 0)
  280. + return -1;
  281. +
  282. return (_rl_vi_change_char (count, c, mb));
  283. }
  284. ***************
  285. *** 1651,1655 ****
  286. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  287. ! if (ch < 'a' || ch > 'z')
  288. {
  289. rl_ding ();
  290. --- 1693,1697 ----
  291. RL_UNSETSTATE(RL_STATE_MOREINPUT);
  292. ! if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
  293. {
  294. rl_ding ();
  295. ***************
  296. *** 1703,1707 ****
  297. return 0;
  298. }
  299. ! else if (ch < 'a' || ch > 'z')
  300. {
  301. rl_ding ();
  302. --- 1745,1749 ----
  303. return 0;
  304. }
  305. ! else if (ch < 0 || ch < 'a' || ch > 'z') /* make test against 0 explicit */
  306. {
  307. rl_ding ();
  308. *** ../bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
  309. --- bash-3.2/patchlevel.h Mon Oct 16 14:22:54 2006
  310. ***************
  311. *** 26,30 ****
  312. looks for to find the patch level (for the sccs version string). */
  313. ! #define PATCHLEVEL 18
  314. #endif /* _PATCHLEVEL_H_ */
  315. --- 26,30 ----
  316. looks for to find the patch level (for the sccs version string). */
  317. ! #define PATCHLEVEL 19
  318. #endif /* _PATCHLEVEL_H_ */