2
1

bash32-010 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 3.2
  4. Patch-ID: bash32-010
  5. Bug-Reported-by: Ryan Waldron <rew@erebor.com>
  6. Bug-Reference-ID: <20070119065603.546D011E9C@kansas.erebor.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2007-01/msg00059.html
  8. Bug-Description:
  9. The glibc implementation of regcomp/regexec does not allow backslashes to
  10. escape "ordinary" pattern characters when matching. Bash used backslashes
  11. to quote all characters when the pattern argument to the [[ special
  12. command's =~ operator was quoted. This caused the match to fail on Linux
  13. and other systems using GNU libc.
  14. Patch:
  15. *** ../bash-3.2.9/pathexp.h Sat Feb 19 17:23:18 2005
  16. --- bash-3.2/pathexp.h Wed Jan 31 22:53:16 2007
  17. ***************
  18. *** 1,5 ****
  19. /* pathexp.h -- The shell interface to the globbing library. */
  20. ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
  21. This file is part of GNU Bash, the Bourne Again SHell.
  22. --- 1,5 ----
  23. /* pathexp.h -- The shell interface to the globbing library. */
  24. ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
  25. This file is part of GNU Bash, the Bourne Again SHell.
  26. ***************
  27. *** 33,36 ****
  28. --- 33,37 ----
  29. #define QGLOB_CVTNULL 0x01 /* convert QUOTED_NULL strings to '\0' */
  30. #define QGLOB_FILENAME 0x02 /* do correct quoting for matching filenames */
  31. + #define QGLOB_REGEXP 0x04 /* quote an ERE for regcomp/regexec */
  32. #if defined (EXTENDED_GLOB)
  33. *** ../bash-3.2.9/pathexp.c Mon May 6 13:43:05 2002
  34. --- bash-3.2/pathexp.c Mon Feb 26 16:59:23 2007
  35. ***************
  36. *** 1,5 ****
  37. /* pathexp.c -- The shell interface to the globbing library. */
  38. ! /* Copyright (C) 1995-2002 Free Software Foundation, Inc.
  39. This file is part of GNU Bash, the Bourne Again SHell.
  40. --- 1,5 ----
  41. /* pathexp.c -- The shell interface to the globbing library. */
  42. ! /* Copyright (C) 1995-2007 Free Software Foundation, Inc.
  43. This file is part of GNU Bash, the Bourne Again SHell.
  44. ***************
  45. *** 111,114 ****
  46. --- 111,141 ----
  47. }
  48. + /* Return 1 if C is a character that is `special' in a POSIX ERE and needs to
  49. + be quoted to match itself. */
  50. + static inline int
  51. + ere_char (c)
  52. + int c;
  53. + {
  54. + switch (c)
  55. + {
  56. + case '.':
  57. + case '[':
  58. + case '\\':
  59. + case '(':
  60. + case ')':
  61. + case '*':
  62. + case '+':
  63. + case '?':
  64. + case '{':
  65. + case '|':
  66. + case '^':
  67. + case '$':
  68. + return 1;
  69. + default:
  70. + return 0;
  71. + }
  72. + return (0);
  73. + }
  74. +
  75. /* PATHNAME can contain characters prefixed by CTLESC; this indicates
  76. that the character is to be quoted. We quote it here in the style
  77. ***************
  78. *** 143,146 ****
  79. --- 170,175 ----
  80. if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/')
  81. continue;
  82. + if ((qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)
  83. + continue;
  84. temp[j++] = '\\';
  85. i++;
  86. *** ../bash-3.2.9/subst.c Tue Nov 7 16:14:41 2006
  87. --- bash-3.2/subst.c Wed Jan 31 23:09:58 2007
  88. ***************
  89. *** 5,9 ****
  90. beauty, but, hey, you're alright.'' */
  91. ! /* Copyright (C) 1987-2006 Free Software Foundation, Inc.
  92. This file is part of GNU Bash, the Bourne Again SHell.
  93. --- 5,9 ----
  94. beauty, but, hey, you're alright.'' */
  95. ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
  96. This file is part of GNU Bash, the Bourne Again SHell.
  97. ***************
  98. *** 2647,2655 ****
  99. /* This needs better error handling. */
  100. /* Expand W for use as an argument to a unary or binary operator in a
  101. ! [[...]] expression. If SPECIAL is nonzero, this is the rhs argument
  102. to the != or == operator, and should be treated as a pattern. In
  103. ! this case, we quote the string specially for the globbing code. The
  104. ! caller is responsible for removing the backslashes if the unquoted
  105. ! words is needed later. */
  106. char *
  107. cond_expand_word (w, special)
  108. --- 2647,2656 ----
  109. /* This needs better error handling. */
  110. /* Expand W for use as an argument to a unary or binary operator in a
  111. ! [[...]] expression. If SPECIAL is 1, this is the rhs argument
  112. to the != or == operator, and should be treated as a pattern. In
  113. ! this case, we quote the string specially for the globbing code. If
  114. ! SPECIAL is 2, this is an rhs argument for the =~ operator, and should
  115. ! be quoted appropriately for regcomp/regexec. The caller is responsible
  116. ! for removing the backslashes if the unquoted word is needed later. */
  117. char *
  118. cond_expand_word (w, special)
  119. ***************
  120. *** 2659,2662 ****
  121. --- 2660,2664 ----
  122. char *r, *p;
  123. WORD_LIST *l;
  124. + int qflags;
  125. if (w->word == 0 || w->word[0] == '\0')
  126. ***************
  127. *** 2673,2678 ****
  128. else
  129. {
  130. p = string_list (l);
  131. ! r = quote_string_for_globbing (p, QGLOB_CVTNULL);
  132. free (p);
  133. }
  134. --- 2675,2683 ----
  135. else
  136. {
  137. + qflags = QGLOB_CVTNULL;
  138. + if (special == 2)
  139. + qflags |= QGLOB_REGEXP;
  140. p = string_list (l);
  141. ! r = quote_string_for_globbing (p, qflags);
  142. free (p);
  143. }
  144. *** ../bash-3.2.9/execute_cmd.c Sat Aug 26 00:23:17 2006
  145. --- bash-3.2/execute_cmd.c Wed Jan 31 23:12:06 2007
  146. ***************
  147. *** 1,5 ****
  148. /* execute_cmd.c -- Execute a COMMAND structure. */
  149. ! /* Copyright (C) 1987-2005 Free Software Foundation, Inc.
  150. This file is part of GNU Bash, the Bourne Again SHell.
  151. --- 1,5 ----
  152. /* execute_cmd.c -- Execute a COMMAND structure. */
  153. ! /* Copyright (C) 1987-2007 Free Software Foundation, Inc.
  154. This file is part of GNU Bash, the Bourne Again SHell.
  155. ***************
  156. *** 2547,2551 ****
  157. if (arg1 == 0)
  158. arg1 = nullstr;
  159. ! arg2 = cond_expand_word (cond->right->op, patmatch||rmatch);
  160. if (arg2 == 0)
  161. arg2 = nullstr;
  162. --- 2547,2551 ----
  163. if (arg1 == 0)
  164. arg1 = nullstr;
  165. ! arg2 = cond_expand_word (cond->right->op, rmatch ? 2 : (patmatch ? 1 : 0));
  166. if (arg2 == 0)
  167. arg2 = nullstr;
  168. *** ../bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
  169. --- bash-3.2/patchlevel.h Mon Oct 16 14:22:54 2006
  170. ***************
  171. *** 26,30 ****
  172. looks for to find the patch level (for the sccs version string). */
  173. ! #define PATCHLEVEL 9
  174. #endif /* _PATCHLEVEL_H_ */
  175. --- 26,30 ----
  176. looks for to find the patch level (for the sccs version string). */
  177. ! #define PATCHLEVEL 10
  178. #endif /* _PATCHLEVEL_H_ */