bash44-007.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. From https://ftp.gnu.org/gnu/bash/bash-4.4-patches/bash44-007
  2. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  3. BASH PATCH REPORT
  4. =================
  5. Bash-Release: 4.4
  6. Patch-ID: bash44-007
  7. Bug-Reported-by: Jens Heyens <jens.heyens@cispa.saarland>
  8. Bug-Reference-ID:
  9. Bug-Reference-URL: https://savannah.gnu.org/support/?109224
  10. Bug-Description:
  11. When performing filename completion, bash dequotes the directory name being
  12. completed, which can result in match failures and potential unwanted
  13. expansion.
  14. Patch (apply with `patch -p0'):
  15. *** bash-4.4-patched/bashline.c 2016-08-05 21:44:05.000000000 -0400
  16. --- b/bashline.c 2017-01-19 13:15:51.000000000 -0500
  17. ***************
  18. *** 143,147 ****
  19. static void restore_directory_hook __P((rl_icppfunc_t));
  20. ! static int directory_exists __P((const char *));
  21. static void cleanup_expansion_error __P((void));
  22. --- b/144,148 ----
  23. static void restore_directory_hook __P((rl_icppfunc_t));
  24. ! static int directory_exists __P((const char *, int));
  25. static void cleanup_expansion_error __P((void));
  26. ***************
  27. *** 3103,3111 ****
  28. }
  29. ! /* Check whether not the (dequoted) version of DIRNAME, with any trailing slash
  30. ! removed, exists. */
  31. static int
  32. ! directory_exists (dirname)
  33. const char *dirname;
  34. {
  35. char *new_dirname;
  36. --- b/3107,3116 ----
  37. }
  38. ! /* Check whether not DIRNAME, with any trailing slash removed, exists. If
  39. ! SHOULD_DEQUOTE is non-zero, we dequote the directory name first. */
  40. static int
  41. ! directory_exists (dirname, should_dequote)
  42. const char *dirname;
  43. + int should_dequote;
  44. {
  45. char *new_dirname;
  46. ***************
  47. *** 3113,3118 ****
  48. struct stat sb;
  49. ! /* First, dequote the directory name */
  50. ! new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character);
  51. dirlen = STRLEN (new_dirname);
  52. if (new_dirname[dirlen - 1] == '/')
  53. --- b/3118,3124 ----
  54. struct stat sb;
  55. ! /* We save the string and chop the trailing slash because stat/lstat behave
  56. ! inconsistently if one is present. */
  57. ! new_dirname = should_dequote ? bash_dequote_filename ((char *)dirname, rl_completion_quote_character) : savestring (dirname);
  58. dirlen = STRLEN (new_dirname);
  59. if (new_dirname[dirlen - 1] == '/')
  60. ***************
  61. *** 3146,3150 ****
  62. should_expand_dirname = '`';
  63. ! if (should_expand_dirname && directory_exists (local_dirname))
  64. should_expand_dirname = 0;
  65. --- b/3152,3156 ----
  66. should_expand_dirname = '`';
  67. ! if (should_expand_dirname && directory_exists (local_dirname, 0))
  68. should_expand_dirname = 0;
  69. ***************
  70. *** 3156,3160 ****
  71. global_nounset = unbound_vars_is_error;
  72. unbound_vars_is_error = 0;
  73. ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
  74. unbound_vars_is_error = global_nounset;
  75. if (wl)
  76. --- b/3162,3166 ----
  77. global_nounset = unbound_vars_is_error;
  78. unbound_vars_is_error = 0;
  79. ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
  80. unbound_vars_is_error = global_nounset;
  81. if (wl)
  82. ***************
  83. *** 3245,3249 ****
  84. }
  85. ! if (should_expand_dirname && directory_exists (local_dirname))
  86. should_expand_dirname = 0;
  87. --- b/3262,3266 ----
  88. }
  89. ! if (should_expand_dirname && directory_exists (local_dirname, 1))
  90. should_expand_dirname = 0;
  91. ***************
  92. *** 3251,3255 ****
  93. {
  94. new_dirname = savestring (local_dirname);
  95. ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */
  96. if (wl)
  97. {
  98. --- b/3268,3272 ----
  99. {
  100. new_dirname = savestring (local_dirname);
  101. ! wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
  102. if (wl)
  103. {
  104. *** bash-4.4/subst.c 2016-08-30 16:46:38.000000000 -0400
  105. --- b/subst.c 2017-01-19 07:09:57.000000000 -0500
  106. ***************
  107. *** 9459,9462 ****
  108. --- b/9459,9466 ----
  109. if (word->flags & W_COMPLETE)
  110. tword->flags |= W_COMPLETE; /* for command substitutions */
  111. + if (word->flags & W_NOCOMSUB)
  112. + tword->flags |= W_NOCOMSUB;
  113. + if (word->flags & W_NOPROCSUB)
  114. + tword->flags |= W_NOPROCSUB;
  115. temp = (char *)NULL;
  116. *** bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
  117. --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
  118. ***************
  119. *** 26,30 ****
  120. looks for to find the patch level (for the sccs version string). */
  121. ! #define PATCHLEVEL 6
  122. #endif /* _PATCHLEVEL_H_ */
  123. --- b/26,30 ----
  124. looks for to find the patch level (for the sccs version string). */
  125. ! #define PATCHLEVEL 7
  126. #endif /* _PATCHLEVEL_H_ */