0001-bash50-001.patch 4.2 KB

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