bash-001-patchlevel1-27.patch 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. Update bash to patchlevel 27.
  2. It's basically a single patch made out from
  3. http://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/ (bash43-001 to 027).
  4. Fixes CVE-2014-6271 (level 25):
  5. Under certain circumstances, bash will execute user code while processing the
  6. environment for exported function definitions.
  7. Level 26-27 are refinements/improved fixes on CVE-2014-6271.
  8. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  9. diff -Nura bash-4.3/arrayfunc.c bash-4.3.pl27/arrayfunc.c
  10. --- bash-4.3/arrayfunc.c 2013-08-02 17:19:59.000000000 -0300
  11. +++ bash-4.3.pl27/arrayfunc.c 2014-09-28 08:13:40.311842889 -0300
  12. @@ -179,6 +179,7 @@
  13. array_insert (array_cell (entry), ind, newval);
  14. FREE (newval);
  15. + VUNSETATTR (entry, att_invisible); /* no longer invisible */
  16. return (entry);
  17. }
  18. @@ -597,6 +598,11 @@
  19. if (assoc_p (var))
  20. {
  21. val = expand_assignment_string_to_string (val, 0);
  22. + if (val == 0)
  23. + {
  24. + val = (char *)xmalloc (1);
  25. + val[0] = '\0'; /* like do_assignment_internal */
  26. + }
  27. free_val = 1;
  28. }
  29. diff -Nura bash-4.3/bashline.c bash-4.3.pl27/bashline.c
  30. --- bash-4.3/bashline.c 2014-02-09 21:56:58.000000000 -0300
  31. +++ bash-4.3.pl27/bashline.c 2014-09-28 08:13:40.312842925 -0300
  32. @@ -4167,9 +4167,16 @@
  33. int qc;
  34. qc = rl_dispatching ? rl_completion_quote_character : 0;
  35. - dfn = bash_dequote_filename ((char *)text, qc);
  36. + /* If rl_completion_found_quote != 0, rl_completion_matches will call the
  37. + filename dequoting function, causing the directory name to be dequoted
  38. + twice. */
  39. + if (rl_dispatching && rl_completion_found_quote == 0)
  40. + dfn = bash_dequote_filename ((char *)text, qc);
  41. + else
  42. + dfn = (char *)text;
  43. m1 = rl_completion_matches (dfn, rl_filename_completion_function);
  44. - free (dfn);
  45. + if (dfn != text)
  46. + free (dfn);
  47. if (m1 == 0 || m1[0] == 0)
  48. return m1;
  49. diff -Nura bash-4.3/builtins/common.h bash-4.3.pl27/builtins/common.h
  50. --- bash-4.3/builtins/common.h 2013-07-08 17:54:47.000000000 -0300
  51. +++ bash-4.3.pl27/builtins/common.h 2014-09-28 08:13:40.313842959 -0300
  52. @@ -33,6 +33,8 @@
  53. #define SEVAL_RESETLINE 0x010
  54. #define SEVAL_PARSEONLY 0x020
  55. #define SEVAL_NOLONGJMP 0x040
  56. +#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */
  57. +#define SEVAL_ONECMD 0x100 /* only allow a single command */
  58. /* Flags for describe_command, shared between type.def and command.def */
  59. #define CDESC_ALL 0x001 /* type -a */
  60. diff -Nura bash-4.3/builtins/evalstring.c bash-4.3.pl27/builtins/evalstring.c
  61. --- bash-4.3/builtins/evalstring.c 2014-02-11 11:42:10.000000000 -0300
  62. +++ bash-4.3.pl27/builtins/evalstring.c 2014-09-28 08:13:40.313842959 -0300
  63. @@ -308,6 +308,14 @@
  64. {
  65. struct fd_bitmap *bitmap;
  66. + if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def)
  67. + {
  68. + internal_warning ("%s: ignoring function definition attempt", from_file);
  69. + should_jump_to_top_level = 0;
  70. + last_result = last_command_exit_value = EX_BADUSAGE;
  71. + break;
  72. + }
  73. +
  74. bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
  75. begin_unwind_frame ("pe_dispose");
  76. add_unwind_protect (dispose_fd_bitmap, bitmap);
  77. @@ -368,6 +376,9 @@
  78. dispose_command (command);
  79. dispose_fd_bitmap (bitmap);
  80. discard_unwind_frame ("pe_dispose");
  81. +
  82. + if (flags & SEVAL_ONECMD)
  83. + break;
  84. }
  85. }
  86. else
  87. diff -Nura bash-4.3/builtins/read.def bash-4.3.pl27/builtins/read.def
  88. --- bash-4.3/builtins/read.def 2013-09-02 12:54:00.000000000 -0300
  89. +++ bash-4.3.pl27/builtins/read.def 2014-09-28 08:13:40.313842959 -0300
  90. @@ -442,7 +442,10 @@
  91. add_unwind_protect (reset_alarm, (char *)NULL);
  92. #if defined (READLINE)
  93. if (edit)
  94. - add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
  95. + {
  96. + add_unwind_protect (reset_attempted_completion_function, (char *)NULL);
  97. + add_unwind_protect (bashline_reset_event_hook, (char *)NULL);
  98. + }
  99. #endif
  100. falarm (tmsec, tmusec);
  101. }
  102. @@ -1021,6 +1024,7 @@
  103. old_attempted_completion_function = rl_attempted_completion_function;
  104. rl_attempted_completion_function = (rl_completion_func_t *)NULL;
  105. + bashline_set_event_hook ();
  106. if (itext)
  107. {
  108. old_startup_hook = rl_startup_hook;
  109. @@ -1032,6 +1036,7 @@
  110. rl_attempted_completion_function = old_attempted_completion_function;
  111. old_attempted_completion_function = (rl_completion_func_t *)NULL;
  112. + bashline_reset_event_hook ();
  113. if (ret == 0)
  114. return ret;
  115. diff -Nura bash-4.3/execute_cmd.c bash-4.3.pl27/execute_cmd.c
  116. --- bash-4.3/execute_cmd.c 2014-01-31 12:54:52.000000000 -0300
  117. +++ bash-4.3.pl27/execute_cmd.c 2014-09-28 08:13:40.315843026 -0300
  118. @@ -2409,7 +2409,16 @@
  119. #endif
  120. lstdin = wait_for (lastpid);
  121. #if defined (JOB_CONTROL)
  122. - exec_result = job_exit_status (lastpipe_jid);
  123. + /* If wait_for removes the job from the jobs table, use result of last
  124. + command as pipeline's exit status as usual. The jobs list can get
  125. + frozen and unfrozen at inconvenient times if there are multiple pipelines
  126. + running simultaneously. */
  127. + if (INVALID_JOB (lastpipe_jid) == 0)
  128. + exec_result = job_exit_status (lastpipe_jid);
  129. + else if (pipefail_opt)
  130. + exec_result = exec_result | lstdin; /* XXX */
  131. + /* otherwise we use exec_result */
  132. +
  133. #endif
  134. unfreeze_jobs_list ();
  135. }
  136. diff -Nura bash-4.3/externs.h bash-4.3.pl27/externs.h
  137. --- bash-4.3/externs.h 2014-01-02 16:58:20.000000000 -0300
  138. +++ bash-4.3.pl27/externs.h 2014-09-28 08:13:40.315843026 -0300
  139. @@ -324,6 +324,7 @@
  140. extern char *sh_backslash_quote __P((char *, const char *, int));
  141. extern char *sh_backslash_quote_for_double_quotes __P((char *));
  142. extern int sh_contains_shell_metas __P((char *));
  143. +extern int sh_contains_quotes __P((char *));
  144. /* declarations for functions defined in lib/sh/spell.c */
  145. extern int spname __P((char *, char *));
  146. diff -Nura bash-4.3/jobs.c bash-4.3.pl27/jobs.c
  147. --- bash-4.3/jobs.c 2014-01-10 11:05:34.000000000 -0300
  148. +++ bash-4.3.pl27/jobs.c 2014-09-28 08:13:40.316843059 -0300
  149. @@ -3597,6 +3597,7 @@
  150. unwind_protect_int (jobs_list_frozen);
  151. unwind_protect_pointer (the_pipeline);
  152. unwind_protect_pointer (subst_assign_varlist);
  153. + unwind_protect_pointer (this_shell_builtin);
  154. /* We have to add the commands this way because they will be run
  155. in reverse order of adding. We don't want maybe_set_sigchld_trap ()
  156. @@ -4374,7 +4375,7 @@
  157. void
  158. end_job_control ()
  159. {
  160. - if (interactive_shell) /* XXX - should it be interactive? */
  161. + if (interactive_shell || job_control) /* XXX - should it be just job_control? */
  162. {
  163. terminate_stopped_jobs ();
  164. diff -Nura bash-4.3/lib/glob/glob.c bash-4.3.pl27/lib/glob/glob.c
  165. --- bash-4.3/lib/glob/glob.c 2014-01-31 23:43:51.000000000 -0300
  166. +++ bash-4.3.pl27/lib/glob/glob.c 2014-09-28 08:13:40.317843093 -0300
  167. @@ -123,6 +123,8 @@
  168. extern char *glob_patscan __P((char *, char *, int));
  169. extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
  170. +extern char *glob_dirscan __P((char *, int));
  171. +
  172. /* Compile `glob_loop.c' for single-byte characters. */
  173. #define CHAR unsigned char
  174. #define INT int
  175. @@ -179,42 +181,53 @@
  176. char *pat, *dname;
  177. int flags;
  178. {
  179. - char *pp, *pe, *t;
  180. - int n, r;
  181. + char *pp, *pe, *t, *se;
  182. + int n, r, negate;
  183. + negate = *pat == '!';
  184. pp = pat + 2;
  185. - pe = pp + strlen (pp) - 1; /*(*/
  186. - if (*pe != ')')
  187. + se = pp + strlen (pp) - 1; /* end of string */
  188. + pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */
  189. + /* we should check for invalid extglob pattern here */
  190. + if (pe == 0)
  191. return 0;
  192. - if ((t = strchr (pp, '|')) == 0) /* easy case first */
  193. +
  194. + /* if pe != se we have more of the pattern at the end of the extglob
  195. + pattern. Check the easy case first ( */
  196. + if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0)
  197. {
  198. *pe = '\0';
  199. +#if defined (HANDLE_MULTIBYTE)
  200. + r = mbskipname (pp, dname, flags);
  201. +#else
  202. r = skipname (pp, dname, flags); /*(*/
  203. +#endif
  204. *pe = ')';
  205. return r;
  206. }
  207. +
  208. + /* check every subpattern */
  209. while (t = glob_patscan (pp, pe, '|'))
  210. {
  211. n = t[-1];
  212. t[-1] = '\0';
  213. +#if defined (HANDLE_MULTIBYTE)
  214. + r = mbskipname (pp, dname, flags);
  215. +#else
  216. r = skipname (pp, dname, flags);
  217. +#endif
  218. t[-1] = n;
  219. if (r == 0) /* if any pattern says not skip, we don't skip */
  220. return r;
  221. pp = t;
  222. } /*(*/
  223. - if (pp == pe) /* glob_patscan might find end of pattern */
  224. + /* glob_patscan might find end of pattern */
  225. + if (pp == se)
  226. return r;
  227. - *pe = '\0';
  228. -# if defined (HANDLE_MULTIBYTE)
  229. - r = mbskipname (pp, dname, flags); /*(*/
  230. -# else
  231. - r = skipname (pp, dname, flags); /*(*/
  232. -# endif
  233. - *pe = ')';
  234. - return r;
  235. + /* but if it doesn't then we didn't match a leading dot */
  236. + return 0;
  237. }
  238. #endif
  239. @@ -277,20 +290,23 @@
  240. int flags;
  241. {
  242. #if EXTENDED_GLOB
  243. - wchar_t *pp, *pe, *t, n;
  244. - int r;
  245. + wchar_t *pp, *pe, *t, n, *se;
  246. + int r, negate;
  247. + negate = *pat == L'!';
  248. pp = pat + 2;
  249. - pe = pp + wcslen (pp) - 1; /*(*/
  250. - if (*pe != L')')
  251. - return 0;
  252. - if ((t = wcschr (pp, L'|')) == 0)
  253. + se = pp + wcslen (pp) - 1; /*(*/
  254. + pe = glob_patscan_wc (pp, se, 0);
  255. +
  256. + if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0)
  257. {
  258. *pe = L'\0';
  259. r = wchkname (pp, dname); /*(*/
  260. *pe = L')';
  261. return r;
  262. }
  263. +
  264. + /* check every subpattern */
  265. while (t = glob_patscan_wc (pp, pe, '|'))
  266. {
  267. n = t[-1];
  268. @@ -305,10 +321,8 @@
  269. if (pp == pe) /* glob_patscan_wc might find end of pattern */
  270. return r;
  271. - *pe = L'\0';
  272. - r = wchkname (pp, dname); /*(*/
  273. - *pe = L')';
  274. - return r;
  275. + /* but if it doesn't then we didn't match a leading dot */
  276. + return 0;
  277. #else
  278. return (wchkname (pat, dname));
  279. #endif
  280. @@ -1006,7 +1020,7 @@
  281. {
  282. char **result;
  283. unsigned int result_size;
  284. - char *directory_name, *filename, *dname;
  285. + char *directory_name, *filename, *dname, *fn;
  286. unsigned int directory_len;
  287. int free_dirname; /* flag */
  288. int dflags;
  289. @@ -1022,6 +1036,18 @@
  290. /* Find the filename. */
  291. filename = strrchr (pathname, '/');
  292. +#if defined (EXTENDED_GLOB)
  293. + if (filename && extended_glob)
  294. + {
  295. + fn = glob_dirscan (pathname, '/');
  296. +#if DEBUG_MATCHING
  297. + if (fn != filename)
  298. + fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename);
  299. +#endif
  300. + filename = fn;
  301. + }
  302. +#endif
  303. +
  304. if (filename == NULL)
  305. {
  306. filename = pathname;
  307. diff -Nura bash-4.3/lib/glob/gmisc.c bash-4.3.pl27/lib/glob/gmisc.c
  308. --- bash-4.3/lib/glob/gmisc.c 2013-10-28 15:45:25.000000000 -0300
  309. +++ bash-4.3.pl27/lib/glob/gmisc.c 2014-09-28 08:13:40.317843093 -0300
  310. @@ -42,6 +42,8 @@
  311. #define WLPAREN L'('
  312. #define WRPAREN L')'
  313. +extern char *glob_patscan __P((char *, char *, int));
  314. +
  315. /* Return 1 of the first character of WSTRING could match the first
  316. character of pattern WPAT. Wide character version. */
  317. int
  318. @@ -210,6 +212,7 @@
  319. case '+':
  320. case '!':
  321. case '@':
  322. + case '?':
  323. return (pat[1] == LPAREN);
  324. default:
  325. return 0;
  326. @@ -374,3 +377,34 @@
  327. return matlen;
  328. }
  329. +
  330. +/* Skip characters in PAT and return the final occurrence of DIRSEP. This
  331. + is only called when extended_glob is set, so we have to skip over extglob
  332. + patterns x(...) */
  333. +char *
  334. +glob_dirscan (pat, dirsep)
  335. + char *pat;
  336. + int dirsep;
  337. +{
  338. + char *p, *d, *pe, *se;
  339. +
  340. + d = pe = se = 0;
  341. + for (p = pat; p && *p; p++)
  342. + {
  343. + if (extglob_pattern_p (p))
  344. + {
  345. + if (se == 0)
  346. + se = p + strlen (p) - 1;
  347. + pe = glob_patscan (p + 2, se, 0);
  348. + if (pe == 0)
  349. + continue;
  350. + else if (*pe == 0)
  351. + break;
  352. + p = pe - 1; /* will do increment above */
  353. + continue;
  354. + }
  355. + if (*p == dirsep)
  356. + d = p;
  357. + }
  358. + return d;
  359. +}
  360. diff -Nura bash-4.3/lib/readline/display.c bash-4.3.pl27/lib/readline/display.c
  361. --- bash-4.3/lib/readline/display.c 2013-12-27 15:10:56.000000000 -0300
  362. +++ bash-4.3.pl27/lib/readline/display.c 2014-09-28 08:13:40.318843127 -0300
  363. @@ -1637,7 +1637,7 @@
  364. /* If we are changing the number of invisible characters in a line, and
  365. the spot of first difference is before the end of the invisible chars,
  366. lendiff needs to be adjusted. */
  367. - if (current_line == 0 && !_rl_horizontal_scroll_mode &&
  368. + if (current_line == 0 && /* !_rl_horizontal_scroll_mode && */
  369. current_invis_chars != visible_wrap_offset)
  370. {
  371. if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
  372. @@ -1825,8 +1825,13 @@
  373. else
  374. _rl_last_c_pos += bytes_to_insert;
  375. + /* XXX - we only want to do this if we are at the end of the line
  376. + so we move there with _rl_move_cursor_relative */
  377. if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
  378. - goto clear_rest_of_line;
  379. + {
  380. + _rl_move_cursor_relative (ne-new, new);
  381. + goto clear_rest_of_line;
  382. + }
  383. }
  384. }
  385. /* Otherwise, print over the existing material. */
  386. @@ -2677,7 +2682,8 @@
  387. {
  388. if (_rl_echoing_p)
  389. {
  390. - _rl_move_vert (_rl_vis_botlin);
  391. + if (_rl_vis_botlin > 0) /* minor optimization plus bug fix */
  392. + _rl_move_vert (_rl_vis_botlin);
  393. _rl_vis_botlin = 0;
  394. fflush (rl_outstream);
  395. rl_restart_output (1, 0);
  396. diff -Nura bash-4.3/lib/readline/input.c bash-4.3.pl27/lib/readline/input.c
  397. --- bash-4.3/lib/readline/input.c 2014-01-10 17:07:08.000000000 -0300
  398. +++ bash-4.3.pl27/lib/readline/input.c 2014-09-28 08:13:40.318843127 -0300
  399. @@ -534,8 +534,16 @@
  400. return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
  401. else if (_rl_caught_signal == SIGHUP || _rl_caught_signal == SIGTERM)
  402. return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
  403. + /* keyboard-generated signals of interest */
  404. else if (_rl_caught_signal == SIGINT || _rl_caught_signal == SIGQUIT)
  405. RL_CHECK_SIGNALS ();
  406. + /* non-keyboard-generated signals of interest */
  407. + else if (_rl_caught_signal == SIGALRM
  408. +#if defined (SIGVTALRM)
  409. + || _rl_caught_signal == SIGVTALRM
  410. +#endif
  411. + )
  412. + RL_CHECK_SIGNALS ();
  413. if (rl_signal_event_hook)
  414. (*rl_signal_event_hook) ();
  415. diff -Nura bash-4.3/lib/readline/misc.c bash-4.3.pl27/lib/readline/misc.c
  416. --- bash-4.3/lib/readline/misc.c 2012-09-01 19:03:11.000000000 -0300
  417. +++ bash-4.3.pl27/lib/readline/misc.c 2014-09-28 08:13:40.319843161 -0300
  418. @@ -461,6 +461,7 @@
  419. saved_undo_list = 0;
  420. /* Set up rl_line_buffer and other variables from history entry */
  421. rl_replace_from_history (entry, 0); /* entry->line is now current */
  422. + entry->data = 0; /* entry->data is now current undo list */
  423. /* Undo all changes to this history entry */
  424. while (rl_undo_list)
  425. rl_do_undo ();
  426. @@ -468,7 +469,6 @@
  427. the timestamp. */
  428. FREE (entry->line);
  429. entry->line = savestring (rl_line_buffer);
  430. - entry->data = 0;
  431. }
  432. entry = previous_history ();
  433. }
  434. diff -Nura bash-4.3/lib/readline/readline.c bash-4.3.pl27/lib/readline/readline.c
  435. --- bash-4.3/lib/readline/readline.c 2013-10-28 15:58:06.000000000 -0300
  436. +++ bash-4.3.pl27/lib/readline/readline.c 2014-09-28 08:13:40.319843161 -0300
  437. @@ -744,7 +744,8 @@
  438. r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
  439. RL_CHECK_SIGNALS ();
  440. - if (r == 0) /* success! */
  441. + /* We only treat values < 0 specially to simulate recursion. */
  442. + if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */
  443. {
  444. _rl_keyseq_chain_dispose ();
  445. RL_UNSETSTATE (RL_STATE_MULTIKEY);
  446. @@ -964,7 +965,7 @@
  447. #if defined (VI_MODE)
  448. if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
  449. key != ANYOTHERKEY &&
  450. - rl_key_sequence_length == 1 && /* XXX */
  451. + _rl_dispatching_keymap == vi_movement_keymap &&
  452. _rl_vi_textmod_command (key))
  453. _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
  454. #endif
  455. diff -Nura bash-4.3/lib/sh/shquote.c bash-4.3.pl27/lib/sh/shquote.c
  456. --- bash-4.3/lib/sh/shquote.c 2013-03-31 22:53:32.000000000 -0300
  457. +++ bash-4.3.pl27/lib/sh/shquote.c 2014-09-28 08:13:40.319843161 -0300
  458. @@ -311,3 +311,17 @@
  459. return (0);
  460. }
  461. +
  462. +int
  463. +sh_contains_quotes (string)
  464. + char *string;
  465. +{
  466. + char *s;
  467. +
  468. + for (s = string; s && *s; s++)
  469. + {
  470. + if (*s == '\'' || *s == '"' || *s == '\\')
  471. + return 1;
  472. + }
  473. + return 0;
  474. +}
  475. diff -Nura bash-4.3/parse.y bash-4.3.pl27/parse.y
  476. --- bash-4.3/parse.y 2014-02-11 11:42:10.000000000 -0300
  477. +++ bash-4.3.pl27/parse.y 2014-09-28 08:14:06.094720199 -0300
  478. @@ -2424,7 +2424,7 @@
  479. not already end in an EOF character. */
  480. if (shell_input_line_terminator != EOF)
  481. {
  482. - if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
  483. + if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
  484. shell_input_line = (char *)xrealloc (shell_input_line,
  485. 1 + (shell_input_line_size += 2));
  486. @@ -2642,7 +2642,7 @@
  487. int r;
  488. r = 0;
  489. - while (need_here_doc)
  490. + while (need_here_doc > 0)
  491. {
  492. parser_state |= PST_HEREDOC;
  493. make_here_document (redir_stack[r++], line_number);
  494. @@ -2953,6 +2953,8 @@
  495. FREE (word_desc_to_read);
  496. word_desc_to_read = (WORD_DESC *)NULL;
  497. + eol_ungetc_lookahead = 0;
  498. +
  499. current_token = '\n'; /* XXX */
  500. last_read_token = '\n';
  501. token_to_read = '\n';
  502. @@ -3398,7 +3400,7 @@
  503. within a double-quoted ${...} construct "an even number of
  504. unescaped double-quotes or single-quotes, if any, shall occur." */
  505. /* This was changed in Austin Group Interp 221 */
  506. - if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
  507. + if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
  508. continue;
  509. /* Could also check open == '`' if we want to parse grouping constructs
  510. @@ -6075,6 +6077,7 @@
  511. ps->expand_aliases = expand_aliases;
  512. ps->echo_input_at_read = echo_input_at_read;
  513. + ps->need_here_doc = need_here_doc;
  514. ps->token = token;
  515. ps->token_buffer_size = token_buffer_size;
  516. @@ -6123,6 +6126,7 @@
  517. expand_aliases = ps->expand_aliases;
  518. echo_input_at_read = ps->echo_input_at_read;
  519. + need_here_doc = ps->need_here_doc;
  520. FREE (token);
  521. token = ps->token;
  522. diff -Nura bash-4.3/patchlevel.h bash-4.3.pl27/patchlevel.h
  523. --- bash-4.3/patchlevel.h 2012-12-29 12:47:57.000000000 -0300
  524. +++ bash-4.3.pl27/patchlevel.h 2014-09-28 08:14:07.486767564 -0300
  525. @@ -25,6 +25,6 @@
  526. regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
  527. looks for to find the patch level (for the sccs version string). */
  528. -#define PATCHLEVEL 0
  529. +#define PATCHLEVEL 27
  530. #endif /* _PATCHLEVEL_H_ */
  531. diff -Nura bash-4.3/pcomplete.c bash-4.3.pl27/pcomplete.c
  532. --- bash-4.3/pcomplete.c 2013-08-26 16:23:45.000000000 -0300
  533. +++ bash-4.3.pl27/pcomplete.c 2014-09-28 08:13:40.321843229 -0300
  534. @@ -183,6 +183,7 @@
  535. COMPSPEC *pcomp_curcs;
  536. const char *pcomp_curcmd;
  537. +const char *pcomp_curtxt;
  538. #ifdef DEBUG
  539. /* Debugging code */
  540. @@ -753,6 +754,32 @@
  541. quoted strings. */
  542. dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
  543. }
  544. + /* Intended to solve a mismatched assumption by bash-completion. If
  545. + the text to be completed is empty, but bash-completion turns it into
  546. + a quoted string ('') assuming that this code will dequote it before
  547. + calling readline, do the dequoting. */
  548. + else if (iscompgen && iscompleting &&
  549. + pcomp_curtxt && *pcomp_curtxt == 0 &&
  550. + text && (*text == '\'' || *text == '"') && text[1] == text[0] && text[2] == 0 &&
  551. + rl_filename_dequoting_function)
  552. + dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
  553. + /* Another mismatched assumption by bash-completion. If compgen is being
  554. + run as part of bash-completion, and the argument to compgen is not
  555. + the same as the word originally passed to the programmable completion
  556. + code, dequote the argument if it has quote characters. It's an
  557. + attempt to detect when bash-completion is quoting its filename
  558. + argument before calling compgen. */
  559. + /* We could check whether gen_shell_function_matches is in the call
  560. + stack by checking whether the gen-shell-function-matches tag is in
  561. + the unwind-protect stack, but there's no function to do that yet.
  562. + We could simply check whether we're executing in a function by
  563. + checking variable_context, and may end up doing that. */
  564. + else if (iscompgen && iscompleting && rl_filename_dequoting_function &&
  565. + pcomp_curtxt && text &&
  566. + STREQ (pcomp_curtxt, text) == 0 &&
  567. + variable_context &&
  568. + sh_contains_quotes (text)) /* guess */
  569. + dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
  570. else
  571. dfn = savestring (text);
  572. }
  573. @@ -1522,7 +1549,7 @@
  574. COMPSPEC **lastcs;
  575. {
  576. COMPSPEC *cs, *oldcs;
  577. - const char *oldcmd;
  578. + const char *oldcmd, *oldtxt;
  579. STRINGLIST *ret;
  580. cs = progcomp_search (ocmd);
  581. @@ -1545,14 +1572,17 @@
  582. oldcs = pcomp_curcs;
  583. oldcmd = pcomp_curcmd;
  584. + oldtxt = pcomp_curtxt;
  585. pcomp_curcs = cs;
  586. pcomp_curcmd = cmd;
  587. + pcomp_curtxt = word;
  588. ret = gen_compspec_completions (cs, cmd, word, start, end, foundp);
  589. pcomp_curcs = oldcs;
  590. pcomp_curcmd = oldcmd;
  591. + pcomp_curtxt = oldtxt;
  592. /* We need to conditionally handle setting *retryp here */
  593. if (retryp)
  594. diff -Nura bash-4.3/shell.h bash-4.3.pl27/shell.h
  595. --- bash-4.3/shell.h 2012-12-25 23:11:01.000000000 -0300
  596. +++ bash-4.3.pl27/shell.h 2014-09-28 08:13:40.321843229 -0300
  597. @@ -168,7 +168,8 @@
  598. /* flags state affecting the parser */
  599. int expand_aliases;
  600. int echo_input_at_read;
  601. -
  602. + int need_here_doc;
  603. +
  604. } sh_parser_state_t;
  605. typedef struct _sh_input_line_state_t {
  606. diff -Nura bash-4.3/subst.c bash-4.3.pl27/subst.c
  607. --- bash-4.3/subst.c 2014-01-23 18:26:37.000000000 -0300
  608. +++ bash-4.3.pl27/subst.c 2014-09-28 08:13:40.322843263 -0300
  609. @@ -1192,12 +1192,18 @@
  610. Start extracting at (SINDEX) as if we had just seen "<(".
  611. Make (SINDEX) get the position of the matching ")". */ /*))*/
  612. char *
  613. -extract_process_subst (string, starter, sindex)
  614. +extract_process_subst (string, starter, sindex, xflags)
  615. char *string;
  616. char *starter;
  617. int *sindex;
  618. + int xflags;
  619. {
  620. +#if 0
  621. return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));
  622. +#else
  623. + xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
  624. + return (xparse_dolparen (string, string+*sindex, sindex, xflags));
  625. +#endif
  626. }
  627. #endif /* PROCESS_SUBSTITUTION */
  628. @@ -1785,7 +1791,7 @@
  629. si = i + 2;
  630. if (string[si] == '\0')
  631. CQ_RETURN(si);
  632. - temp = extract_process_subst (string, (c == '<') ? "<(" : ">(", &si);
  633. + temp = extract_process_subst (string, (c == '<') ? "<(" : ">(", &si, 0);
  634. free (temp); /* no SX_ALLOC here */
  635. i = si;
  636. if (string[i] == '\0')
  637. @@ -3248,8 +3254,10 @@
  638. if (w->word == 0 || w->word[0] == '\0')
  639. return ((char *)NULL);
  640. + expand_no_split_dollar_star = 1;
  641. w->flags |= W_NOSPLIT2;
  642. l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);
  643. + expand_no_split_dollar_star = 0;
  644. if (l)
  645. {
  646. if (special == 0) /* LHS */
  647. @@ -7366,7 +7374,13 @@
  648. }
  649. if (want_indir)
  650. - tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at);
  651. + {
  652. + tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at);
  653. + /* Turn off the W_ARRAYIND flag because there is no way for this function
  654. + to return the index we're supposed to be using. */
  655. + if (tdesc && tdesc->flags)
  656. + tdesc->flags &= ~W_ARRAYIND;
  657. + }
  658. else
  659. tdesc = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND|(pflags&(PF_NOSPLIT2|PF_ASSIGNRHS)), &ind);
  660. @@ -7847,6 +7861,10 @@
  661. We also want to make sure that splitting is done no matter what --
  662. according to POSIX.2, this expands to a list of the positional
  663. parameters no matter what IFS is set to. */
  664. + /* XXX - what to do when in a context where word splitting is not
  665. + performed? Even when IFS is not the default, posix seems to imply
  666. + that we behave like unquoted $* ? Maybe we should use PF_NOSPLIT2
  667. + here. */
  668. temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted);
  669. tflag |= W_DOLLARAT;
  670. @@ -8029,7 +8047,9 @@
  671. goto return0;
  672. }
  673. - else if (var = find_variable_last_nameref (temp1))
  674. + else if (var && (invisible_p (var) || var_isset (var) == 0))
  675. + temp = (char *)NULL;
  676. + else if ((var = find_variable_last_nameref (temp1)) && var_isset (var) && invisible_p (var) == 0)
  677. {
  678. temp = nameref_cell (var);
  679. #if defined (ARRAY_VARS)
  680. @@ -8243,7 +8263,7 @@
  681. else
  682. t_index = sindex + 1; /* skip past both '<' and LPAREN */
  683. - temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index); /*))*/
  684. + temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index, 0); /*))*/
  685. sindex = t_index;
  686. /* If the process substitution specification is `<()', we want to
  687. @@ -8816,6 +8836,7 @@
  688. else
  689. {
  690. char *ifs_chars;
  691. + char *tstring;
  692. ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
  693. @@ -8830,11 +8851,36 @@
  694. regardless of what else has happened to IFS since the expansion. */
  695. if (split_on_spaces)
  696. list = list_string (istring, " ", 1); /* XXX quoted == 1? */
  697. + /* If we have $@ (has_dollar_at != 0) and we are in a context where we
  698. + don't want to split the result (W_NOSPLIT2), and we are not quoted,
  699. + we have already separated the arguments with the first character of
  700. + $IFS. In this case, we want to return a list with a single word
  701. + with the separator possibly replaced with a space (it's what other
  702. + shells seem to do).
  703. + quoted_dollar_at is internal to this function and is set if we are
  704. + passed an argument that is unquoted (quoted == 0) but we encounter a
  705. + double-quoted $@ while expanding it. */
  706. + else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
  707. + {
  708. + /* Only split and rejoin if we have to */
  709. + if (*ifs_chars && *ifs_chars != ' ')
  710. + {
  711. + list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
  712. + tstring = string_list (list);
  713. + }
  714. + else
  715. + tstring = istring;
  716. + tword = make_bare_word (tstring);
  717. + if (tstring != istring)
  718. + free (tstring);
  719. + goto set_word_flags;
  720. + }
  721. else if (has_dollar_at && ifs_chars)
  722. list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
  723. else
  724. {
  725. tword = make_bare_word (istring);
  726. +set_word_flags:
  727. if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
  728. tword->flags |= W_QUOTED;
  729. if (word->flags & W_ASSIGNMENT)
  730. diff -Nura bash-4.3/subst.h bash-4.3.pl27/subst.h
  731. --- bash-4.3/subst.h 2014-01-11 23:02:27.000000000 -0300
  732. +++ bash-4.3.pl27/subst.h 2014-09-28 08:13:40.322843263 -0300
  733. @@ -82,7 +82,7 @@
  734. /* Extract the <( or >( construct in STRING, and return a new string.
  735. Start extracting at (SINDEX) as if we had just seen "<(".
  736. Make (SINDEX) get the position just after the matching ")". */
  737. -extern char *extract_process_subst __P((char *, char *, int *));
  738. +extern char *extract_process_subst __P((char *, char *, int *, int));
  739. #endif /* PROCESS_SUBSTITUTION */
  740. /* Extract the name of the variable to bind to from the assignment string. */
  741. diff -Nura bash-4.3/test.c bash-4.3.pl27/test.c
  742. --- bash-4.3/test.c 2014-02-04 18:52:58.000000000 -0300
  743. +++ bash-4.3.pl27/test.c 2014-09-28 08:13:40.323843297 -0300
  744. @@ -646,8 +646,8 @@
  745. return (v && invisible_p (v) == 0 && var_isset (v) ? TRUE : FALSE);
  746. case 'R':
  747. - v = find_variable (arg);
  748. - return (v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v) ? TRUE : FALSE);
  749. + v = find_variable_noref (arg);
  750. + return ((v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v)) ? TRUE : FALSE);
  751. }
  752. /* We can't actually get here, but this shuts up gcc. */
  753. @@ -723,6 +723,7 @@
  754. case 'o': case 'p': case 'r': case 's': case 't':
  755. case 'u': case 'v': case 'w': case 'x': case 'z':
  756. case 'G': case 'L': case 'O': case 'S': case 'N':
  757. + case 'R':
  758. return (1);
  759. }
  760. diff -Nura bash-4.3/trap.c bash-4.3.pl27/trap.c
  761. --- bash-4.3/trap.c 2014-02-05 12:03:21.000000000 -0300
  762. +++ bash-4.3.pl27/trap.c 2014-09-28 08:13:40.323843297 -0300
  763. @@ -920,7 +920,8 @@
  764. subst_assign_varlist = 0;
  765. #if defined (JOB_CONTROL)
  766. - save_pipeline (1); /* XXX only provides one save level */
  767. + if (sig != DEBUG_TRAP) /* run_debug_trap does this */
  768. + save_pipeline (1); /* XXX only provides one save level */
  769. #endif
  770. /* If we're in a function, make sure return longjmps come here, too. */
  771. @@ -940,7 +941,8 @@
  772. trap_exit_value = last_command_exit_value;
  773. #if defined (JOB_CONTROL)
  774. - restore_pipeline (1);
  775. + if (sig != DEBUG_TRAP) /* run_debug_trap does this */
  776. + restore_pipeline (1);
  777. #endif
  778. subst_assign_varlist = save_subst_varlist;
  779. diff -Nura bash-4.3/variables.c bash-4.3.pl27/variables.c
  780. --- bash-4.3/variables.c 2014-02-14 13:55:12.000000000 -0300
  781. +++ bash-4.3.pl27/variables.c 2014-09-28 08:14:07.486767564 -0300
  782. @@ -83,6 +83,11 @@
  783. #define ifsname(s) ((s)[0] == 'I' && (s)[1] == 'F' && (s)[2] == 'S' && (s)[3] == '\0')
  784. +#define BASHFUNC_PREFIX "BASH_FUNC_"
  785. +#define BASHFUNC_PREFLEN 10 /* == strlen(BASHFUNC_PREFIX */
  786. +#define BASHFUNC_SUFFIX "%%"
  787. +#define BASHFUNC_SUFFLEN 2 /* == strlen(BASHFUNC_SUFFIX) */
  788. +
  789. extern char **environ;
  790. /* Variables used here and defined in other files. */
  791. @@ -279,7 +284,7 @@
  792. static void propagate_temp_var __P((PTR_T));
  793. static void dispose_temporary_env __P((sh_free_func_t *));
  794. -static inline char *mk_env_string __P((const char *, const char *));
  795. +static inline char *mk_env_string __P((const char *, const char *, int));
  796. static char **make_env_array_from_var_list __P((SHELL_VAR **));
  797. static char **make_var_export_array __P((VAR_CONTEXT *));
  798. static char **make_func_export_array __P((void));
  799. @@ -349,24 +354,33 @@
  800. /* If exported function, define it now. Don't import functions from
  801. the environment in privileged mode. */
  802. - if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
  803. + if (privmode == 0 && read_but_dont_execute == 0 &&
  804. + STREQN (BASHFUNC_PREFIX, name, BASHFUNC_PREFLEN) &&
  805. + STREQ (BASHFUNC_SUFFIX, name + char_index - BASHFUNC_SUFFLEN) &&
  806. + STREQN ("() {", string, 4))
  807. {
  808. - string_length = strlen (string);
  809. - temp_string = (char *)xmalloc (3 + string_length + char_index);
  810. + size_t namelen;
  811. + char *tname; /* desired imported function name */
  812. - strcpy (temp_string, name);
  813. - temp_string[char_index] = ' ';
  814. - strcpy (temp_string + char_index + 1, string);
  815. + namelen = char_index - BASHFUNC_PREFLEN - BASHFUNC_SUFFLEN;
  816. - if (posixly_correct == 0 || legal_identifier (name))
  817. - parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
  818. + tname = name + BASHFUNC_PREFLEN; /* start of func name */
  819. + tname[namelen] = '\0'; /* now tname == func name */
  820. +
  821. + string_length = strlen (string);
  822. + temp_string = (char *)xmalloc (namelen + string_length + 2);
  823. - /* Ancient backwards compatibility. Old versions of bash exported
  824. - functions like name()=() {...} */
  825. - if (name[char_index - 1] == ')' && name[char_index - 2] == '(')
  826. - name[char_index - 2] = '\0';
  827. + memcpy (temp_string, tname, namelen);
  828. + temp_string[namelen] = ' ';
  829. + memcpy (temp_string + namelen + 1, string, string_length + 1);
  830. +
  831. + /* Don't import function names that are invalid identifiers from the
  832. + environment, though we still allow them to be defined as shell
  833. + variables. */
  834. + if (absolute_program (tname) == 0 && (posixly_correct == 0 || legal_identifier (tname)))
  835. + parse_and_execute (temp_string, tname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
  836. - if (temp_var = find_function (name))
  837. + if (temp_var = find_function (tname))
  838. {
  839. VSETATTR (temp_var, (att_exported|att_imported));
  840. array_needs_making = 1;
  841. @@ -379,12 +393,11 @@
  842. array_needs_making = 1;
  843. }
  844. last_command_exit_value = 1;
  845. - report_error (_("error importing function definition for `%s'"), name);
  846. + report_error (_("error importing function definition for `%s'"), tname);
  847. }
  848. - /* ( */
  849. - if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
  850. - name[char_index - 2] = '('; /* ) */
  851. + /* Restore original suffix */
  852. + tname[namelen] = BASHFUNC_SUFFIX[0];
  853. }
  854. #if defined (ARRAY_VARS)
  855. # if ARRAY_EXPORT
  856. @@ -2197,10 +2210,7 @@
  857. /* local foo; local foo; is a no-op. */
  858. old_var = find_variable (name);
  859. if (old_var && local_p (old_var) && old_var->context == variable_context)
  860. - {
  861. - VUNSETATTR (old_var, att_invisible); /* XXX */
  862. - return (old_var);
  863. - }
  864. + return (old_var);
  865. was_tmpvar = old_var && tempvar_p (old_var);
  866. /* If we're making a local variable in a shell function, the temporary env
  867. @@ -2963,7 +2973,7 @@
  868. var->context = variable_context; /* XXX */
  869. INVALIDATE_EXPORTSTR (var);
  870. - var->exportstr = mk_env_string (name, value);
  871. + var->exportstr = mk_env_string (name, value, 0);
  872. array_needs_making = 1;
  873. @@ -3861,21 +3871,42 @@
  874. /* **************************************************************** */
  875. static inline char *
  876. -mk_env_string (name, value)
  877. +mk_env_string (name, value, isfunc)
  878. const char *name, *value;
  879. + int isfunc;
  880. {
  881. - int name_len, value_len;
  882. - char *p;
  883. + size_t name_len, value_len;
  884. + char *p, *q;
  885. name_len = strlen (name);
  886. value_len = STRLEN (value);
  887. - p = (char *)xmalloc (2 + name_len + value_len);
  888. - strcpy (p, name);
  889. - p[name_len] = '=';
  890. +
  891. + /* If we are exporting a shell function, construct the encoded function
  892. + name. */
  893. + if (isfunc && value)
  894. + {
  895. + p = (char *)xmalloc (BASHFUNC_PREFLEN + name_len + BASHFUNC_SUFFLEN + value_len + 2);
  896. + q = p;
  897. + memcpy (q, BASHFUNC_PREFIX, BASHFUNC_PREFLEN);
  898. + q += BASHFUNC_PREFLEN;
  899. + memcpy (q, name, name_len);
  900. + q += name_len;
  901. + memcpy (q, BASHFUNC_SUFFIX, BASHFUNC_SUFFLEN);
  902. + q += BASHFUNC_SUFFLEN;
  903. + }
  904. + else
  905. + {
  906. + p = (char *)xmalloc (2 + name_len + value_len);
  907. + memcpy (p, name, name_len);
  908. + q = p + name_len;
  909. + }
  910. +
  911. + q[0] = '=';
  912. if (value && *value)
  913. - strcpy (p + name_len + 1, value);
  914. + memcpy (q + 1, value, value_len + 1);
  915. else
  916. - p[name_len + 1] = '\0';
  917. + q[1] = '\0';
  918. +
  919. return (p);
  920. }
  921. @@ -3961,7 +3992,7 @@
  922. /* Gee, I'd like to get away with not using savestring() if we're
  923. using the cached exportstr... */
  924. list[list_index] = USE_EXPORTSTR ? savestring (value)
  925. - : mk_env_string (var->name, value);
  926. + : mk_env_string (var->name, value, function_p (var));
  927. if (USE_EXPORTSTR == 0)
  928. SAVE_EXPORTSTR (var, list[list_index]);
  929. diff -Nura bash-4.3/y.tab.c bash-4.3.pl27/y.tab.c
  930. --- bash-4.3/y.tab.c 2014-02-11 12:57:47.000000000 -0300
  931. +++ bash-4.3.pl27/y.tab.c 2014-09-28 08:14:06.096720267 -0300
  932. @@ -4736,7 +4736,7 @@
  933. not already end in an EOF character. */
  934. if (shell_input_line_terminator != EOF)
  935. {
  936. - if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
  937. + if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
  938. shell_input_line = (char *)xrealloc (shell_input_line,
  939. 1 + (shell_input_line_size += 2));
  940. @@ -4954,7 +4954,7 @@
  941. int r;
  942. r = 0;
  943. - while (need_here_doc)
  944. + while (need_here_doc > 0)
  945. {
  946. parser_state |= PST_HEREDOC;
  947. make_here_document (redir_stack[r++], line_number);
  948. @@ -5265,6 +5265,8 @@
  949. FREE (word_desc_to_read);
  950. word_desc_to_read = (WORD_DESC *)NULL;
  951. + eol_ungetc_lookahead = 0;
  952. +
  953. current_token = '\n'; /* XXX */
  954. last_read_token = '\n';
  955. token_to_read = '\n';
  956. @@ -5710,7 +5712,7 @@
  957. within a double-quoted ${...} construct "an even number of
  958. unescaped double-quotes or single-quotes, if any, shall occur." */
  959. /* This was changed in Austin Group Interp 221 */
  960. - if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
  961. + if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
  962. continue;
  963. /* Could also check open == '`' if we want to parse grouping constructs
  964. @@ -8387,6 +8389,7 @@
  965. ps->expand_aliases = expand_aliases;
  966. ps->echo_input_at_read = echo_input_at_read;
  967. + ps->need_here_doc = need_here_doc;
  968. ps->token = token;
  969. ps->token_buffer_size = token_buffer_size;
  970. @@ -8435,6 +8438,7 @@
  971. expand_aliases = ps->expand_aliases;
  972. echo_input_at_read = ps->echo_input_at_read;
  973. + need_here_doc = ps->need_here_doc;
  974. FREE (token);
  975. token = ps->token;
  976. @@ -8537,4 +8541,3 @@
  977. }
  978. }
  979. #endif /* HANDLE_MULTIBYTE */
  980. -