bash44-009.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. From https://ftp.gnu.org/gnu/bash/bash-4.4-patches/bash44-009
  2. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  3. BASH PATCH REPORT
  4. =================
  5. Bash-Release: 4.4
  6. Patch-ID: bash44-009
  7. Bug-Reported-by: Hong Cho <hong.cho@citrix.com>
  8. Bug-Reference-ID: <c30b5fe62b2543af8297e47ca487c29c@SJCPEX02CL02.citrite.net>
  9. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2016-12/msg00043.html
  10. Bug-Description:
  11. There is a race condition in add_history() that can be triggered by a fatal
  12. signal arriving between the time the history length is updated and the time
  13. the history list update is completed. A later attempt to reference an
  14. invalid history entry can cause a crash.
  15. Patch (apply with `patch -p0'):
  16. *** bash-4.4-patched/lib/readline/history.c 2016-11-11 13:42:49.000000000 -0500
  17. --- b/lib/readline/history.c 2016-12-05 10:37:51.000000000 -0500
  18. ***************
  19. *** 280,283 ****
  20. --- b/280,284 ----
  21. {
  22. HIST_ENTRY *temp;
  23. + int new_length;
  24. if (history_stifled && (history_length == history_max_entries))
  25. ***************
  26. *** 296,306 ****
  27. /* Copy the rest of the entries, moving down one slot. Copy includes
  28. trailing NULL. */
  29. - #if 0
  30. - for (i = 0; i < history_length; i++)
  31. - the_history[i] = the_history[i + 1];
  32. - #else
  33. memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *));
  34. - #endif
  35. history_base++;
  36. }
  37. --- b/297,303 ----
  38. /* Copy the rest of the entries, moving down one slot. Copy includes
  39. trailing NULL. */
  40. memmove (the_history, the_history + 1, history_length * sizeof (HIST_ENTRY *));
  41. + new_length = history_length;
  42. history_base++;
  43. }
  44. ***************
  45. *** 316,320 ****
  46. history_size = DEFAULT_HISTORY_INITIAL_SIZE;
  47. the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
  48. ! history_length = 1;
  49. }
  50. else
  51. --- b/313,317 ----
  52. history_size = DEFAULT_HISTORY_INITIAL_SIZE;
  53. the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
  54. ! new_length = 1;
  55. }
  56. else
  57. ***************
  58. *** 326,330 ****
  59. xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
  60. }
  61. ! history_length++;
  62. }
  63. }
  64. --- b/323,327 ----
  65. xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
  66. }
  67. ! new_length = history_length + 1;
  68. }
  69. }
  70. ***************
  71. *** 332,337 ****
  72. temp = alloc_history_entry ((char *)string, hist_inittime ());
  73. ! the_history[history_length] = (HIST_ENTRY *)NULL;
  74. ! the_history[history_length - 1] = temp;
  75. }
  76. --- b/329,335 ----
  77. temp = alloc_history_entry ((char *)string, hist_inittime ());
  78. ! the_history[new_length] = (HIST_ENTRY *)NULL;
  79. ! the_history[new_length - 1] = temp;
  80. ! history_length = new_length;
  81. }
  82. *** bash-4.4/patchlevel.h 2016-06-22 14:51:03.000000000 -0400
  83. --- b/patchlevel.h 2016-10-01 11:01:28.000000000 -0400
  84. ***************
  85. *** 26,30 ****
  86. looks for to find the patch level (for the sccs version string). */
  87. ! #define PATCHLEVEL 8
  88. #endif /* _PATCHLEVEL_H_ */
  89. --- b/26,30 ----
  90. looks for to find the patch level (for the sccs version string). */
  91. ! #define PATCHLEVEL 9
  92. #endif /* _PATCHLEVEL_H_ */