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.

166 lines
4.0 KiB

  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 5.0
  4. Patch-ID: bash50-001
  5. Bug-Reported-by: axel@freakout.de
  6. Bug-Reference-ID: <201901082050.x08KoShS006731@bongo.freakout.de>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00079.html
  8. Bug-Description:
  9. Under certain circumstances, the glob expansion code did not remove
  10. backslashes escaping characters in directory names (or portions of a
  11. pattern preceding a slash).
  12. Patch (apply with `patch -p0'):
  13. *** a/bashline.c 2018-11-27 13:20:16.000000000 -0500
  14. --- b/bashline.c 2019-01-16 16:06:03.000000000 -0500
  15. ***************
  16. *** 232,235 ****
  17. --- 232,236 ----
  18. static int bash_possible_command_completions __P((int, int));
  19. + static int completion_glob_pattern __P((char *));
  20. static char *glob_complete_word __P((const char *, int));
  21. static int bash_glob_completion_internal __P((int));
  22. ***************
  23. *** 1742,1746 ****
  24. /* This could be a globbing pattern, so try to expand it using pathname
  25. expansion. */
  26. ! if (!matches && glob_pattern_p (text))
  27. {
  28. matches = rl_completion_matches (text, glob_complete_word);
  29. --- 1743,1747 ----
  30. /* This could be a globbing pattern, so try to expand it using pathname
  31. expansion. */
  32. ! if (!matches && completion_glob_pattern ((char *)text))
  33. {
  34. matches = rl_completion_matches (text, glob_complete_word);
  35. ***************
  36. *** 1851,1855 ****
  37. }
  38. ! globpat = glob_pattern_p (hint_text);
  39. /* If this is an absolute program name, do not check it against
  40. --- 1852,1856 ----
  41. }
  42. ! globpat = completion_glob_pattern ((char *)hint_text);
  43. /* If this is an absolute program name, do not check it against
  44. ***************
  45. *** 3714,3717 ****
  46. --- 3715,3773 ----
  47. }
  48. + static int
  49. + completion_glob_pattern (string)
  50. + char *string;
  51. + {
  52. + register int c;
  53. + char *send;
  54. + int open;
  55. +
  56. + DECLARE_MBSTATE;
  57. +
  58. + open = 0;
  59. + send = string + strlen (string);
  60. +
  61. + while (c = *string++)
  62. + {
  63. + switch (c)
  64. + {
  65. + case '?':
  66. + case '*':
  67. + return (1);
  68. +
  69. + case '[':
  70. + open++;
  71. + continue;
  72. +
  73. + case ']':
  74. + if (open)
  75. + return (1);
  76. + continue;
  77. +
  78. + case '+':
  79. + case '@':
  80. + case '!':
  81. + if (*string == '(') /*)*/
  82. + return (1);
  83. + continue;
  84. +
  85. + case '\\':
  86. + if (*string == 0)
  87. + return (0);
  88. + }
  89. +
  90. + /* Advance one fewer byte than an entire multibyte character to
  91. + account for the auto-increment in the loop above. */
  92. + #ifdef HANDLE_MULTIBYTE
  93. + string--;
  94. + ADVANCE_CHAR_P (string, send - string);
  95. + string++;
  96. + #else
  97. + ADVANCE_CHAR_P (string, send - string);
  98. + #endif
  99. + }
  100. + return (0);
  101. + }
  102. +
  103. static char *globtext;
  104. static char *globorig;
  105. ***************
  106. *** 3878,3882 ****
  107. }
  108. ! if (t && glob_pattern_p (t) == 0)
  109. rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
  110. FREE (t);
  111. --- 3934,3938 ----
  112. }
  113. ! if (t && completion_glob_pattern (t) == 0)
  114. rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
  115. FREE (t);
  116. *** a/lib/glob/glob_loop.c 2018-12-31 13:35:15.000000000 -0500
  117. --- b/lib/glob/glob_loop.c 2019-01-09 09:44:36.000000000 -0500
  118. ***************
  119. *** 55,59 ****
  120. case L('\\'):
  121. - #if 0
  122. /* Don't let the pattern end in a backslash (GMATCH returns no match
  123. if the pattern ends in a backslash anyway), but otherwise return 1,
  124. --- 55,58 ----
  125. ***************
  126. *** 61,69 ****
  127. and it can be removed. */
  128. return (*p != L('\0'));
  129. - #else
  130. - /* The pattern may not end with a backslash. */
  131. - if (*p++ == L('\0'))
  132. - return 0;
  133. - #endif
  134. }
  135. --- 60,63 ----
  136. *** a/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
  137. --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
  138. ***************
  139. *** 26,30 ****
  140. looks for to find the patch level (for the sccs version string). */
  141. ! #define PATCHLEVEL 0
  142. #endif /* _PATCHLEVEL_H_ */
  143. --- 26,30 ----
  144. looks for to find the patch level (for the sccs version string). */
  145. ! #define PATCHLEVEL 1
  146. #endif /* _PATCHLEVEL_H_ */