mirror of the now-defunct rocklinux.org
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.

147 lines
4.5 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 3.2
  4. Patch-ID: bash32-003
  5. Bug-Reported-by: John Gatewood Ham <zappaman@buraphalinux.org>
  6. Bug-Reference-ID: <Pine.LNX.4.64.0610121334140.15558@www.buraphalinux.org>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-10/msg00045.html
  8. Bug-Description:
  9. When using the conditional command's `=~' operator to match regular
  10. expressions, the parser did not skip over shell metacharacters in the
  11. regular expression, leading to syntax errors.
  12. Patch:
  13. *** bash-3.2-patched/parse.y Tue Oct 17 11:45:20 2006
  14. --- parse.y Sat Oct 14 14:56:16 2006
  15. ***************
  16. *** 1029,1034 ****
  17. --- 1029,1035 ----
  18. #define PST_CMDTOKEN 0x1000 /* command token OK - unused */
  19. #define PST_COMPASSIGN 0x2000 /* parsing x=(...) compound assignment */
  20. #define PST_ASSIGNOK 0x4000 /* assignment statement ok in this context */
  21. + #define PST_REGEXP 0x8000 /* parsing an ERE/BRE as a single word */
  22. /* Initial size to allocate for tokens, and the
  23. amount to grow them by. */
  24. ***************
  25. *** 2591,2596 ****
  26. --- 2592,2600 ----
  27. return (character);
  28. }
  29. + if (parser_state & PST_REGEXP)
  30. + goto tokword;
  31. +
  32. /* Shell meta-characters. */
  33. if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
  34. {
  35. ***************
  36. *** 2698,2703 ****
  37. --- 2702,2708 ----
  38. if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
  39. return (character);
  40. + tokword:
  41. /* Okay, if we got this far, we have to read a word. Read one,
  42. and then check it against the known ones. */
  43. result = read_token_word (character);
  44. ***************
  45. *** 3202,3209 ****
  46. if (tok == WORD && test_binop (yylval.word->word))
  47. op = yylval.word;
  48. #if defined (COND_REGEXP)
  49. ! else if (tok == WORD && STREQ (yylval.word->word,"=~"))
  50. ! op = yylval.word;
  51. #endif
  52. else if (tok == '<' || tok == '>')
  53. op = make_word_from_token (tok); /* ( */
  54. --- 3207,3217 ----
  55. if (tok == WORD && test_binop (yylval.word->word))
  56. op = yylval.word;
  57. #if defined (COND_REGEXP)
  58. ! else if (tok == WORD && STREQ (yylval.word->word, "=~"))
  59. ! {
  60. ! op = yylval.word;
  61. ! parser_state |= PST_REGEXP;
  62. ! }
  63. #endif
  64. else if (tok == '<' || tok == '>')
  65. op = make_word_from_token (tok); /* ( */
  66. ***************
  67. *** 3234,3239 ****
  68. --- 3242,3248 ----
  69. /* rhs */
  70. tok = read_token (READ);
  71. + parser_state &= ~PST_REGEXP;
  72. if (tok == WORD)
  73. {
  74. tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
  75. ***************
  76. *** 3419,3427 ****
  77. goto next_character;
  78. }
  79. #ifdef EXTENDED_GLOB
  80. /* Parse a ksh-style extended pattern matching specification. */
  81. ! if (extended_glob && PATTERN_CHAR (character))
  82. {
  83. peek_char = shell_getc (1);
  84. if MBTEST(peek_char == '(') /* ) */
  85. --- 3428,3461 ----
  86. goto next_character;
  87. }
  88. + #ifdef COND_REGEXP
  89. + /* When parsing a regexp as a single word inside a conditional command,
  90. + we need to special-case characters special to both the shell and
  91. + regular expressions. Right now, that is only '(' and '|'. */ /*)*/
  92. + if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
  93. + {
  94. + if (character == '|')
  95. + goto got_character;
  96. +
  97. + push_delimiter (dstack, character);
  98. + ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
  99. + pop_delimiter (dstack);
  100. + if (ttok == &matched_pair_error)
  101. + return -1; /* Bail immediately. */
  102. + RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
  103. + token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
  104. + token[token_index++] = character;
  105. + strcpy (token + token_index, ttok);
  106. + token_index += ttoklen;
  107. + FREE (ttok);
  108. + dollar_present = all_digit_token = 0;
  109. + goto next_character;
  110. + }
  111. + #endif /* COND_REGEXP */
  112. +
  113. #ifdef EXTENDED_GLOB
  114. /* Parse a ksh-style extended pattern matching specification. */
  115. ! if MBTEST(extended_glob && PATTERN_CHAR (character))
  116. {
  117. peek_char = shell_getc (1);
  118. if MBTEST(peek_char == '(') /* ) */
  119. *** bash-3.2/patchlevel.h Thu Apr 13 08:31:04 2006
  120. --- patchlevel.h Mon Oct 16 14:22:54 2006
  121. ***************
  122. *** 26,30 ****
  123. looks for to find the patch level (for the sccs version string). */
  124. ! #define PATCHLEVEL 2
  125. #endif /* _PATCHLEVEL_H_ */
  126. --- 26,30 ----
  127. looks for to find the patch level (for the sccs version string). */
  128. ! #define PATCHLEVEL 3
  129. #endif /* _PATCHLEVEL_H_ */