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.

106 lines
4.2 KiB

  1. Index: bash-4.4/patchlevel.h
  2. ===================================================================
  3. --- bash-4.4.orig/patchlevel.h
  4. +++ bash-4.4/patchlevel.h
  5. @@ -25,6 +25,6 @@
  6. regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
  7. looks for to find the patch level (for the sccs version string). */
  8. -#define PATCHLEVEL 11
  9. +#define PATCHLEVEL 12
  10. #endif /* _PATCHLEVEL_H_ */
  11. Index: bash-4.4/subst.c
  12. ===================================================================
  13. --- bash-4.4.orig/subst.c
  14. +++ bash-4.4/subst.c
  15. @@ -2825,11 +2825,15 @@ list_string (string, separators, quoted)
  16. /* Parse a single word from STRING, using SEPARATORS to separate fields.
  17. ENDPTR is set to the first character after the word. This is used by
  18. - the `read' builtin. This is never called with SEPARATORS != $IFS;
  19. - it should be simplified.
  20. + the `read' builtin.
  21. +
  22. + This is never called with SEPARATORS != $IFS, and takes advantage of that.
  23. XXX - this function is very similar to list_string; they should be
  24. combined - XXX */
  25. +
  26. +#define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0)
  27. +
  28. char *
  29. get_word_from_string (stringp, separators, endptr)
  30. char **stringp, *separators, **endptr;
  31. @@ -2837,6 +2841,7 @@ get_word_from_string (stringp, separator
  32. register char *s;
  33. char *current_word;
  34. int sindex, sh_style_split, whitesep, xflags;
  35. + unsigned char local_cmap[UCHAR_MAX+1]; /* really only need single-byte chars here */
  36. size_t slen;
  37. if (!stringp || !*stringp || !**stringp)
  38. @@ -2846,20 +2851,23 @@ get_word_from_string (stringp, separator
  39. separators[1] == '\t' &&
  40. separators[2] == '\n' &&
  41. separators[3] == '\0';
  42. - for (xflags = 0, s = ifs_value; s && *s; s++)
  43. + memset (local_cmap, '\0', sizeof (local_cmap));
  44. + for (xflags = 0, s = separators; s && *s; s++)
  45. {
  46. if (*s == CTLESC) xflags |= SX_NOCTLESC;
  47. if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
  48. + local_cmap[(unsigned char)*s] = 1; /* local charmap of separators */
  49. }
  50. s = *stringp;
  51. slen = 0;
  52. /* Remove sequences of whitespace at the beginning of STRING, as
  53. - long as those characters appear in IFS. */
  54. - if (sh_style_split || !separators || !*separators)
  55. + long as those characters appear in SEPARATORS. This happens if
  56. + SEPARATORS == $' \t\n' or if IFS is unset. */
  57. + if (sh_style_split || separators == 0)
  58. {
  59. - for (; *s && spctabnl (*s) && isifs (*s); s++);
  60. + for (; *s && spctabnl (*s) && islocalsep (*s); s++);
  61. /* If the string is nothing but whitespace, update it and return. */
  62. if (!*s)
  63. @@ -2878,9 +2886,9 @@ get_word_from_string (stringp, separator
  64. This obeys the field splitting rules in Posix.2. */
  65. sindex = 0;
  66. - /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
  67. - unless multibyte chars are possible. */
  68. - slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1;
  69. + /* Don't need string length in ADVANCE_CHAR unless multibyte chars are
  70. + possible, but need it in string_extract_verbatim for bounds checking */
  71. + slen = STRLEN (s);
  72. current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
  73. /* Set ENDPTR to the first character after the end of the word. */
  74. @@ -2899,19 +2907,19 @@ get_word_from_string (stringp, separator
  75. /* Now skip sequences of space, tab, or newline characters if they are
  76. in the list of separators. */
  77. - while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
  78. + while (s[sindex] && spctabnl (s[sindex]) && islocalsep (s[sindex]))
  79. sindex++;
  80. /* If the first separator was IFS whitespace and the current character is
  81. a non-whitespace IFS character, it should be part of the current field
  82. delimiter, not a separate delimiter that would result in an empty field.
  83. Look at POSIX.2, 3.6.5, (3)(b). */
  84. - if (s[sindex] && whitesep && isifs (s[sindex]) && !spctabnl (s[sindex]))
  85. + if (s[sindex] && whitesep && islocalsep (s[sindex]) && !spctabnl (s[sindex]))
  86. {
  87. sindex++;
  88. /* An IFS character that is not IFS white space, along with any adjacent
  89. IFS white space, shall delimit a field. */
  90. - while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
  91. + while (s[sindex] && spctabnl (s[sindex]) && islocalsep(s[sindex]))
  92. sindex++;
  93. }