bash44-012 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 4.4
  4. Patch-ID: bash44-012
  5. Bug-Reported-by: Clark Wang <dearvoid@gmail.com>
  6. Bug-Reference-ID: <CADv8-ojttPUFOZXqbjsvy83LfaJtQKZ5qejGdF6j0VJ3vtrYOA@mail.gmail.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-11/msg00106.html
  8. Bug-Description:
  9. When -N is used, the input is not supposed to be split using $IFS, but
  10. leading and trailing IFS whitespace was still removed.
  11. Patch (apply with `patch -p0'):
  12. *** ../bash-4.4-patched/subst.c 2017-01-20 14:22:01.000000000 -0500
  13. --- subst.c 2017-01-25 13:43:22.000000000 -0500
  14. ***************
  15. *** 2826,2834 ****
  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. XXX - this function is very similar to list_string; they should be
  21. combined - XXX */
  22. char *
  23. get_word_from_string (stringp, separators, endptr)
  24. --- 2826,2838 ----
  25. /* Parse a single word from STRING, using SEPARATORS to separate fields.
  26. ENDPTR is set to the first character after the word. This is used by
  27. ! the `read' builtin.
  28. !
  29. ! This is never called with SEPARATORS != $IFS, and takes advantage of that.
  30. XXX - this function is very similar to list_string; they should be
  31. combined - XXX */
  32. +
  33. + #define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0)
  34. +
  35. char *
  36. get_word_from_string (stringp, separators, endptr)
  37. ***************
  38. *** 2838,2841 ****
  39. --- 2842,2846 ----
  40. char *current_word;
  41. int sindex, sh_style_split, whitesep, xflags;
  42. + unsigned char local_cmap[UCHAR_MAX+1]; /* really only need single-byte chars here */
  43. size_t slen;
  44. ***************
  45. *** 2847,2854 ****
  46. separators[2] == '\n' &&
  47. separators[3] == '\0';
  48. ! for (xflags = 0, s = ifs_value; s && *s; s++)
  49. {
  50. if (*s == CTLESC) xflags |= SX_NOCTLESC;
  51. if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
  52. }
  53. --- 2852,2861 ----
  54. separators[2] == '\n' &&
  55. separators[3] == '\0';
  56. ! memset (local_cmap, '\0', sizeof (local_cmap));
  57. ! for (xflags = 0, s = separators; s && *s; s++)
  58. {
  59. if (*s == CTLESC) xflags |= SX_NOCTLESC;
  60. if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
  61. + local_cmap[(unsigned char)*s] = 1; /* local charmap of separators */
  62. }
  63. ***************
  64. *** 2857,2864 ****
  65. /* Remove sequences of whitespace at the beginning of STRING, as
  66. ! long as those characters appear in IFS. */
  67. ! if (sh_style_split || !separators || !*separators)
  68. {
  69. ! for (; *s && spctabnl (*s) && isifs (*s); s++);
  70. /* If the string is nothing but whitespace, update it and return. */
  71. --- 2864,2872 ----
  72. /* Remove sequences of whitespace at the beginning of STRING, as
  73. ! long as those characters appear in SEPARATORS. This happens if
  74. ! SEPARATORS == $' \t\n' or if IFS is unset. */
  75. ! if (sh_style_split || separators == 0)
  76. {
  77. ! for (; *s && spctabnl (*s) && islocalsep (*s); s++);
  78. /* If the string is nothing but whitespace, update it and return. */
  79. ***************
  80. *** 2879,2885 ****
  81. This obeys the field splitting rules in Posix.2. */
  82. sindex = 0;
  83. ! /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim
  84. ! unless multibyte chars are possible. */
  85. ! slen = (MB_CUR_MAX > 1) ? STRLEN (s) : 1;
  86. current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
  87. --- 2887,2893 ----
  88. This obeys the field splitting rules in Posix.2. */
  89. sindex = 0;
  90. ! /* Don't need string length in ADVANCE_CHAR unless multibyte chars are
  91. ! possible, but need it in string_extract_verbatim for bounds checking */
  92. ! slen = STRLEN (s);
  93. current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);
  94. ***************
  95. *** 2900,2904 ****
  96. /* Now skip sequences of space, tab, or newline characters if they are
  97. in the list of separators. */
  98. ! while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
  99. sindex++;
  100. --- 2908,2912 ----
  101. /* Now skip sequences of space, tab, or newline characters if they are
  102. in the list of separators. */
  103. ! while (s[sindex] && spctabnl (s[sindex]) && islocalsep (s[sindex]))
  104. sindex++;
  105. ***************
  106. *** 2907,2916 ****
  107. delimiter, not a separate delimiter that would result in an empty field.
  108. Look at POSIX.2, 3.6.5, (3)(b). */
  109. ! if (s[sindex] && whitesep && isifs (s[sindex]) && !spctabnl (s[sindex]))
  110. {
  111. sindex++;
  112. /* An IFS character that is not IFS white space, along with any adjacent
  113. IFS white space, shall delimit a field. */
  114. ! while (s[sindex] && spctabnl (s[sindex]) && isifs (s[sindex]))
  115. sindex++;
  116. }
  117. --- 2915,2924 ----
  118. delimiter, not a separate delimiter that would result in an empty field.
  119. Look at POSIX.2, 3.6.5, (3)(b). */
  120. ! if (s[sindex] && whitesep && islocalsep (s[sindex]) && !spctabnl (s[sindex]))
  121. {
  122. sindex++;
  123. /* An IFS character that is not IFS white space, along with any adjacent
  124. IFS white space, shall delimit a field. */
  125. ! while (s[sindex] && spctabnl (s[sindex]) && islocalsep(s[sindex]))
  126. sindex++;
  127. }
  128. *** ../bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
  129. --- patchlevel.h 2016-10-01 11:01:28.000000000 -0400
  130. ***************
  131. *** 26,30 ****
  132. looks for to find the patch level (for the sccs version string). */
  133. ! #define PATCHLEVEL 11
  134. #endif /* _PATCHLEVEL_H_ */
  135. --- 26,30 ----
  136. looks for to find the patch level (for the sccs version string). */
  137. ! #define PATCHLEVEL 12
  138. #endif /* _PATCHLEVEL_H_ */