bash44-007 4.5 KB

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